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

According to his methodology what all you need before you build a datawarehouse

1290


can any one give some examples for pre sql and post sql(Except dropping and creating index).

3618


What are the transformations that cannot be placed between the sort origin and the joiner transformation so that we do not lose the input sort order?

881


tell me the rules and responsblites in our project(my project is development)

1604


Enlist the differences between database and data warehouse.

638






How to improve the performance of a session using sorter transformation?

788


What are the different types of repositories created using informatica?

758


WHAT IS EDM?WHAT IS THE USE IN INFORMATICA? chandumba2005@gmai.com

1621


what is INFORMATICA TESTING process

1943


What is the sql query overwrite in source qualifier in informatica

708


What is informatica worklet?

699


How to differentiate between the active and passive transformations?

709


Explain pushdown optimization $pushdownconfig parameter - informatica

812


How you can differentiate between connected lookup and unconnected lookup?

709


3.how will u get information about bugs how will u rectify the bugs in realtime whch tool we are using to rectify the bugs

1845