Author |
Topic |
Sadhu
Starting Member
14 Posts |
Posted - 2014-12-19 : 00:21:03
|
Sample Data :EventBID, EventID, Archived DateE1, 1, 12/10/2014E2, 1, 12/18/2014E3, 1, NULLE4, 2, NULL E5, 2, NULLE6, 2, NULLE7, 3, 11/08/2014E8, 3, NULLE9, 4, NULLE10, 4, NULLI want to get the EVENTIDs that are having all the ArchiveDates for EventBIDs as NULL.Output :24 |
|
MuralikrishnaVeera
Posting Yak Master
129 Posts |
Posted - 2014-12-19 : 01:33:17
|
[code]create table #x (EventBID varchar(10),EventID INT,[Archived Date] varchar(100))insert into #xselect 'E1',1,'12/10/2014' union allselect 'pat',1,'12/18/2014' union allselect 'E3', 1, NULL union allselect 'E4', 2, NULL union allselect 'E5', 2, NULL union allselect 'E6', 2, NULL union allselect 'E7', 3,'11/08/2014' union allselect 'E8', 3, NULL union allselect 'E9', 4, NULL union allselect 'E10', 4, NULL SELECT DISTINCT EventID FROM dbo.#x WHERE [Archived Date] IS NULL AND EventID NOT IN (SELECT EventID From #x WHERE [Archived Date] IS NOT NULL )DROP Table #x[/code]---------------Murali KrishnaYou live only once ..If you do it right once is enough....... |
|
|
|
|
|