All Forums Database
rychitre 25 posts Joined 04/07
28 Aug 2016
Merge different rows in one row

I have huge data as below. ‘Act_dt,cust_id and cust_line_id’ should be unique key.

act_dt cust_id cust_line_id flg1 flg2 flg3 metric1 metric2 metric3
1-Jul   1111    1                       D                20
1-Jul   1111    1                 N          M                 10 
1-Jul   1111    1                 N                                        5
       
I want to have only 1 record as below.

act_dt cust_id cust_line_id flg1 flg2 flg3 metric1 metric2 metric3
1-Jul   1111    1                N    D    M     10        20         5

How can I do this? Can someone help?
 

29 Aug 2016

You could do this:
SEL Act_dt,cust_id and cust_line_id,MAX(flg1), MAX(flg2), MAX(flg3), MAX(metric1), MAX(metric2), MAX(metric3) 
FROM <TABLE>
GROUP BY 1,2,3

You must sign in to leave a comment.