gaganHR
gaganHR

Reputation: 337

Combine multiple records to one

I have multiple records that I want to group into a single record. The multiple records have are having ranges. The resultant record should just contain the range. for ex: In the below example I am having 6 records all having similar data except for colum 5 shown as c5. The resultant table has 7 columns having the range. Please request for any assistance to go about this. Many Thanks, Gagan

    scenario:

    c1  c2  c3  c4  c5  c6  
    -----------------------
    AA  BB  CC  DD  1   FF

    AA  BB  CC  DD  2   FF

    AA  BB  CC  DD  3   FF

    AA  BB  CC  DD  4   FF

    AA  BB  CC  DD  5   FF

    AA  BB  CC  DD  6   FF


    result record:

    c1  c2  c3  c4  c5  c6  c7
    --------------------------
    AA  BB  CC  DD  1   6  FF

Upvotes: 0

Views: 67

Answers (1)

BaconSah
BaconSah

Reputation: 421

How about using a group by and a min and max?

Select c1,c2,c3,c4,min(c5), max(c5), c6 from [table] group by c1,c2,c3,c4,c6

Will that not work for you?

Upvotes: 1

Related Questions