【发布时间】:2013-11-21 11:17:47
【问题描述】:
这是我想要实现的基本示例:
create table #testing (
tab varchar(max), a int, b int, c int )
insert into #testing VALUES ('x',1, 2, 3)
insert into #testing VALUES ('y',1, 2, 3)
insert into #testing VALUES ('x', 4, 5, 6)
select * from #testing
这将产生表格:
tab a b c
-----------------------
x 1 2 3
y 1 2 3
x 4 5 6
然后我想根据 a、b、c 的值比较“选项卡”上的行:
select a,b,c from #testing where tab = 'x'
except
select a,b,c from #testing where tab= 'y'
这给了我所期待的答案:
a b c
------------
4 5 6
但是我还想在我的结果集中包含 Tab 列,所以我想要这样的东西:
Select tab,a,b,c from #testing where ????
(select a,b,c from #testing where tab = 'x'
except
select a,b,c from #testing where tab= 'y')
我将如何实现这一目标?
【问题讨论】:
标签: sql sql-server tsql sql-server-2005