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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 query result....need help

Author  Topic 

hai
Yak Posting Veteran

84 Posts

Posted - 2008-07-14 : 16:35:41
I have the following:
ID x1 y1 y2 y3 y4 y5
1234 1 1 0 0 0 0
1234 1 0 1 0 0 0
1234 1 0 0 1 0 0
1234 1 0 0 0 1 0
1234 2 0 1 0 0 0
1234 2 0 0 1 0 0
1234 2 0 0 0 1 0
1234 2 0 0 0 0 1
1234 3 1 0 0 0 0
1234 3 0 1 0 0 0
1234 3 0 0 0 1 0
1234 4 1 0 0 0 0
1234 4 0 0 1 0 0
1234 4 0 0 0 1 0
1234 4 0 0 0 0 1

I would like the result to return as below.

ID x1 y1 y2 y3 y4 y5
1234 1 1 1 1 1 0
1234 2 0 1 1 1 1
1234 3 1 1 0 1 0
1234 4 1 0 1 1 1

thanks

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-07-14 : 16:55:37
select id, x1, max(y1), max(y2),...
from YourTable
group by id, x1
Go to Top of Page
   

- Advertisement -