Merge different rows in one row

Database

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?

1 REPLY

Re: Merge different rows in one row

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