Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Combining multiple rows into one row Expand / Collapse
Author
Message
Posted Friday, July 18, 2014 11:44 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, August 25, 2014 3:23 AM
Points: 7, Visits: 33
I have a table in sql server which has more than 100 columns with rows like this

eg:
IDKEY INTKey HRI STRID1 CID SEG T L TMP
71073287 877699 9839 131025521 84046D 2 0 0 0
71072766 877699 9839 131025521 84046D 2 0.61 0.2 1050.24
71072767 877699 9839 131025521 84046D 3 0 0.26 1059.71
71073288 877699 9839 131025521 84046D 3 0.81 0 0
71073288 877699 9839 131025521 84046D 3 0 0 0
71072566 877699 9839 131025521 84046D 4 0 0.33 0
71072768 877699 9839 131025521 84046D 4 1.02 0
71073870 877699 9839 131025521 84046D 4 0 0 1062.8

I need to combine the rows with same CID and SEG into one row and delete the others.
eg
IDKEY INTKey HRI STRID1 CID SEG T L TMP
71073287 877699 9839 131025521 84046D 2 0.61 0.2 1050.24
71072767 877699 9839 131025521 84046D 3 0.81 0.26 1059.71
71072566 877699 9839 131025521 84046D 4 1.02 0.33 1062.8


How can this be done??
Post #1594290
Posted Saturday, July 19, 2014 2:38 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 2:32 PM
Points: 1,912, Visits: 19,379
will GROUP BY and MAX do it to get the new rows?

edit...whats the business rule for IDKEY...??


______________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Post #1594297
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse