Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mike26
Starting Member
5 Posts |
Posted - 2012-02-10 : 15:52:09
|
| I have the following table:ID COL1 COL2 COL3 COL4 1 A NULL 15 NULL1 A TEST1 NULL NULL1 A NULL NULL ABC2 B NULL 10 NULL2 B TEST2 NULL EFGI would like to get the following table from the above tableID COL1 COL2 COL3 COL41 A TEST1 15 ABC2 B TEST2 10 EFGI have tried self join and checking for null values but so far I haven't been able to get it right. Any suggestions would be appreciated. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-10 : 16:00:25
|
| [code]SELECT ID,COL1,MAX(COL2) AS COL2,MAX(COL3) AS COL3,MAX(COL4) AS COL4FROM TableGROUP BY ID,COL1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
mike26
Starting Member
5 Posts |
Posted - 2012-02-10 : 16:02:57
|
| It worked. Thanks a bunch. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-10 : 16:03:41
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|