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 / jj

without one more column its not possible i thing , it shoud
have prod or some thing

select prod,sum(q1),sum(q2),sum(q3),sum(q4) from (
select prod,(case when quarter='q1' then sal end) q1
,(case when quarter='q2' then sal end) q2
,(case when quarter='q3' then sal end) q3
,(case when quarter='q4' then sal end) q4 from za)
group by prod

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

As union transformation gives UNION ALL output, how you will get the UNION output?

730


How to join three sources using joiner? Explain though mapping flow.

782


Explain what are the different versions of informatica?

758


What is a repository manager?

739


What happen if you have 3 ports in SQ and 4 ports in SQL override of SQ( provided all ports are in same order and they are connected with proper source and target)? Also what happens when I have 4 ports and will extract 3 values in SQloverride.. What will be the value in 4th port ?

1283






what are the best practices to extract data from flat file source which are bigger than 100 mb memory?

2019


What is the difference between Active and Passive transformation?

736


Explain pushdown optimization and types in informatica

747


What is aggregator transformation in informatica?

628


How might one distinguish in the case of mapping is right or not without associating session?

733


Explain how many types of dimensions are available in informatica?

680


Design a mapping to get the pervious row salary for the current row. If there is no pervious row exists for the current row, then the pervious row salary should be displayed as null.

892


Enterprise data warehouse your projects phase by phase explain?

1562


What is the difference between a connected look up and unconnected lookup?

656


How can we delete duplicate rows from flat files?

847