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

what is $$$$?

1732


Repository user profiles

1373


What is a rank transform?

670


How does a sorter cache works?

563


Explain the tuning lookup transformation - informatica

607






What are the types of caches in lookup?

564


What are the various types of transformation?

639


Differentiate between a repository server and a powerhouse?

571


What are the different types of transformation available in informatica.

632


Source and Target are flat files, Source table is as below ID,NAME 1,X 1,X 2,Y 2,Y On Target flat file i want the data to be loaded as mentioned below ID,NAME,REPEAT 1,X,2 1,X,2 2,Y,2 2,Y,2 How to achieve this, Can i get a map structure

6464


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

658


What is the status code in stored procedure transformation?

683


i have a data in my source as a flat files what test i have to perform the next step can any body help to me

1695


What are batches?

617


Design a mapping to load the cumulative sum of salaries of employees into target table?

889