write a query to follwoing table
amount year quarter
254556 2003 first
546332 2003 second
129034 2003 third
490223 2003 fourth
165768 2004 first
265443 2004 second
510412 2004 third
435690 2004 fourth
i want the output
year q1_amount q2_amount q3_amount q4_amount
2003 254556 546332 129034 490223
2004 165768 265443 510412 435690
Answer Posted / ankit kansal
The above answer is perfectly fine, however you can achieve the same using case
Select YEAR,SUM(q1_amt)q1_amt,SUM(q2_amt)q2_amt,SUM(q3_amt)
q3_amt,SUM(q4_amt)q4_amt from (
select YEAR,
CASE QUARTER WHEN 'first' THEN amount ELSE 0 END as q1_amt,
CASE QUARTER WHEN 'second' THEN amount ELSE 0 END as q2_amt,
CASE QUARTER WHEN 'third' THEN amount ELSE 0 END as q3_amt,
CASE QUARTER WHEN 'fourth' THEN amount ELSE 0 END as q4_amt
from t_name) temp group by YEAR;
http://deepinopensource.blogspot.in/
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is Active lock explain
What is a filter transformation?
Why sorter is an active transformation?
if we have a delimiters at unwanted places in a flat file how can we over come those.
which one is better performance wise joiner or look up
Explain is there any way to read the ms excel datas directly into informatica? Like is there any possibilities to take excel file as target?
How do you update the records with or without using update strategy?
Define pmcmd command?
What are the restrictions of union transformation?
How to elaborate tracing level?
Enlist the differences between database and data warehouse.
In What Situations we can use MappingParameters ,Mapping Variables AND Session Parameters in REAL TIME.
What is the advantage of informatica?
What are the components of Informatica? And what is the purpose of each?
How to go to the older version for a mapping?