July 19, 2016 at 4:35 am
declare @sample table
(
ID int,
s1 varchar(10),
s2 varchar(10)
)
insert into @sample values (1, 'A' , null )
insert into @sample values (1, null, 'C' )
select * from @sample
i need output like this
ID S1 S2
1 A C
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
July 19, 2016 at 5:09 am
Quick suggestion, add max on the values and group by the ID.
😎
July 21, 2016 at 10:46 am
There are quite a few good articles on the internet with examples.
https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
August 3, 2016 at 1:55 am
select id,max(s1) value1 ,max(s2) value2 from @sample group by id
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply