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
 Rows and Column mapping

Author  Topic 

goodman2253
Yak Posting Veteran

88 Posts

Posted - 2014-11-03 : 07:59:19
Hello
How are you guys, Once again I stuck with a problem and need help from you guys.

The Source Data is

ID--VAL1--VAL2--VAL3--VAL4--VAL5--VAL6
1---151---- ----- ----- Y----- -----
2---151---- -----Y----- -----Y-----Y
3---152----Y----- ------ ----- ------
4---152---- -----Y------ ----Y------


The Expected Output should be

ID--VAL1--VAL2--VAL3--VAL4--VAL5--VAL6
1--151----- ----Y------Y-----Y-----Y
2--152-----Y-----Y------ -----Y-----


Thanks

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-11-03 : 08:40:47
[code]select
dense_rank() over (order by val1) as ID,
val1,
max(val2) as VAL2, max(val3) as VAL4,
max(val4) as VAL4, max(val5) as VAL5, max(val6) as VAL6
from
YourTable
group by
val1;[/code]
Go to Top of Page
   

- Advertisement -