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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Simple Query Question

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2014-12-09 : 14:13:11
Hi all - I have the following table:
[CODE]
EMP# ID1 ID2 ID3 ID4
123 FR64 NULL NULL NULL
123 NULL NULL NULL 12GH
123 NULL AB46 NULL NULL

[/code]
I'd like the output to eliminate as much NULLs as possible, and display all the possible "IDs" one on row per employee.
[CODE]
EMP# ID1 ID2 ID3 ID4
123 FR64 AB46 NULL 12GH
[/CODE]
Any ideas?
[CODE]
SELECT EMP#, ID1, ID2, ID3, ID4 FROM TABLE T1
[/CODE]

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-09 : 14:34:41
[code]
select emp#, max(ID1) + ',' + max(id2) ...
from ..
group by emp#
[/code]
Go to Top of Page
   

- Advertisement -