write sql query following table

quarter sales
q1 1000
q1 2000
q1 3000
q1 4000
q2 5000
q2 6000
q2 7000
q2 8000
q3 1000
q3 2000
q3 3000
q3 4000
q4 5000
q4 6000
q4 7000
q4 8000
i want the output format like
q1 q2 q3 q4
1000 5000 1000 5000
2000 6000 2000 6000
3000 7000 3000 7000
4000 8000 4000 8000

Answer Posted / ankit kansal

one solution can be like this


select max(q1) as q1,max(q2) as q2,max(q3) as q3,max(q4) as q4 from
(
select case when quarter = 'q1' then sales end q1
,case when quarter = 'q2' then sales end q2
,case when quarter = 'q3' then sales end q3
,case when quarter = 'q4' then sales end q4
,row_number() over ( partition by quarter order by 1 ) rnk

from sequel_test order by 5

)tb group by rnk order by 1,2,3,4

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to do unit testing in informatica? How to load data in informatica ?

641


Explain direct and indirect flat file loading (source file type) - informatica

817


How do you remove duplicate records in informatica? And how many ways are there to do it?

702


How to extract the informatica rejected data?

743


IN SCD1, insource we have 10 billion records and in the first day its uploaded successfully and in the second day its taking time to upload because some records it might get update or insert new records. As a developer what will be the better solution for this??

551






Quickly characterize reusable change?

683


Explain the aggregator transformation?

621


how to construct simple biogas digerter? please show me detail drawing and specification of simple biogas construction?

1964


Suppose on 1st Nov 2010 you had created a mapping which includes huge aggregator calculations and it is under process for next two days. You will notice that even on 3rd day also its still calculating. So without changing a logic or changing a mapping How will you troubleshot or to run that mapping? Explain the steps

1615


What are the conditions needed to improve the performance of informatica aggregator transformation?

577


How can we create index after completion of load process?

592


tell me 5 session failure in real time how can you solve that in your project?

1627


explain one complex mapping with logic? sales project?

6135


Which transformation is needed while using the Cobol sources as source definitions?

721


If the source has duplicate records as id and name columns, values: 1 a, 1 b, 1 c, 2 a, 2 b, the target should be loaded as 1 a+b+c or 1 a||b||c, what transformations should be used for this?

8525