write sql query following table
amount year quarter
1000 2003 first
2000 2003 second
3000 2003 third
4000 2003 fourth
5000 2004 first
6000 2004 second
7000 2004 third
8000 2004 fourth

i want the output
year q1_amount q2_amount q3_amount q4_amount
2003 1000 2000 3000 4000
2004 5000 6000 7000 8000

Answer Posted / chanakya123

SELECT YEAR,
SUM(DECODE(QUARTER,'FIRST',AMOUNT)) Q1_AMOUNT ,
SUM(DECODE(QUARTER,'SECOND',AMOUNT)) Q2_AMOUNT,
SUM(DECODE(QUARTER,'THIRD',AMOUNT)) Q3_AMOUNT,
SUM(DECODE(QUARTER,'FOURTH',AMOUNT)) Q4_AMOUNT
FROM TABLE_NAME GROUP BY YEAR

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why update strategy and union transformations are active? Explain with examples.

724


What is a repository manager?

660


Explain where to store informatica rejected data? How to extract the informatica rejected data?

588


Why filter transformation is an active one?

577


How do you update the records with or without using update strategy?

676






in reporting we add some new objects,how we get the count of the newly added objects to the report

1764


How do you set a varible in incremental aggregation

1457


What is Story point Estimation ? Can any one give just an introduction about this ? Advance Thanks

4812


difference between repository database and repository service?

632


what is granularity,what type of granularity we will take in fact tables either lowlevel or highlevel,if two tables having same granularity that is posiable or not

1882


What is target load order?

814


what are the fact table & dimensional table in pharmaceutical and hospotal related products???

1707


what is the end to end process meaning in my project(my project is development)and functionality plz tell me

1509


what is mean by complex business rule ?

1727


What is event and what are the tasks related to it?

626