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
Answers were Sorted based on User's Feedback
Answer / letc
Using max function for q1,q2,q3,q4 in Aggregator transformation. Use sorter before aggregator
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / 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 |
Answer / 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 |
can u any challenge your project?
HOW CAN I SEND HALF OF THE RECORDS TO ONE TARGET AND REMAINING TO OTHER TARGET?
To provide support for Mainframes source data,which files r used as a COBOL files
What are mapplets? How is it different from a Reusable Transformation?
i have 50500 records in my source.if wf run for the first time it will load 1000 records into 1 tgt,if runs second time it will load to another tgt.targets are FF and it is need to be created dynamically.how many tgt will be created and how?
in my source i have 100 records, and 3 targets, i want to load 1st record into 1st target,2nd record into 2nd target,3rd record into 3rd target again 4th target into 1st target and vice versa,how to achieve this?
Hi ETL gurus can any one tell me with a flow how to implement SCD Type 1 and SCD Type 2 in a single mapping.For some fields SCD type has to be implemented and for some fields scd type has to be implementd..Thank in advance..please let me know in case of any concerns...
What is the function of union transformation?
what is the dashbords?
How mapping parameter and variable works
how do u fnd the duplicate rows and how to delete the duplicate rows?
hi, as al you know, we can set the option in session level as all rows treat as like insert,update etc., And also we have update strategy for flaging records as insert,update etc.. then when we will go for above options and what is the difference.. explain..