user3010811
user3010811

Reputation: 1

Same table, two statements, need the difference between the two

I am an English major stumbling my way around very basic SQL Stuff. I have gotten the follwing two statements to return the results I need (both from the same table):

select *
from Table1
where Column1 = 'Examplel' and UniqueID is not null
order by UniqueID2

(2000 lines returned)

select *
from Table1
where Column1 = 'Examplel'
and ColumnDATE between '2008-02-12 00:00:00.000' and '2013-08-15 00:00:00.000'
order by UniqueID2

(2001 lines returned)

I need to find that one line of difference, prefereably without scrolling and comparing all lines in both results. Help?

Upvotes: 0

Views: 62

Answers (2)

MarcinJuraszek
MarcinJuraszek

Reputation: 125620

select *
from Table1
where Column1 = 'Examplel'
and ColumnDATE between '2008-02-12 00:00:00.000' and '2013-08-15 00:00:00.000
and UniqueID is null
order by UniqueID2

Upvotes: 1

AaronLS
AaronLS

Reputation: 38367

Run this all as one statement:

select * from Table1 where Column1 = 'Examplel' and UniqueID is not null order by UniqueID2

except

select * from Table1 where Column1 = 'Examplel' and ColumnDATE between '2008-02-12 00:00:00.000' and '2013-08-15 00:00:00.000' order by UniqueID2

Then run the reverse:

select * from Table1 where Column1 = 'Examplel' and ColumnDATE between '2008-02-12 00:00:00.000' and '2013-08-15 00:00:00.000' order by UniqueID2

except

select * from Table1 where Column1 = 'Examplel' and UniqueID is not null order by UniqueID2

Upvotes: 1

Related Questions