Declare @test table ( calldate date, calllogid int, id int ) Insert into @test select '2013-12-02', 52713, 48287 Insert into @test select '2013-12-02', 52713, 271 Insert into @test select '2014-05-01', 71817,NULL Insert into @test select '2014-05-01', 71817, 62805 Insert into @test select '2014-02-28', 63995, NULL Select * from @test order by calllogid
Above is temp table with sample data and below is the output I'm looking for..
calldate calllogid id 2013-12-02 52713 48287 2013-12-02 52713 271 2014-02-28 63995 NULL 2014-05-01 71817 62805
Say suppose, if a callogid is having multiple id's I'm interested to display both. And which if one is null I just want to show not null record for that calllogid, in above for calllogid 71817 I'm only interested in seeing not null record. and If the calllogid has only one record with null id, I would like to show that as well..
I can achieve with rank function but this dealing with NULL giving me issue.Help is appreciated.
- please mark correct answers