0

我是一名英语专业的学生,​​在非常基本的 SQL Stuff 上磕磕绊绊。我得到了以下两个语句来返回我需要的结果(都来自同一个表):

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

(返回 2000 行)

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 行)

我需要找到那一行差异,最好不要滚动和比较两个结果中的所有行。帮助?

4

2 回答 2

1
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
于 2013-11-19T22:21:41.667 回答
1

将这一切作为一个语句运行:

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

然后反向运行:

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
于 2013-11-19T22:20:02.433 回答