根据日期检查来自同一表的记录,其中包含多行中的不匹配值

问题描述 投票:-2回答:1

我想从同一个表中选择不匹配的组合:

表格1

enter image description here

因此,根据上表,#Id组合(#3,#4,#5)在2018年9月15日失踪,#Id组合(#8,#9,#10)在15-Sep完全不同-2018与2018年9月14日相比。

所以我想选择这样的ID [#Id组合(#8,#9,#10)]并打印出来

我如何通过查询找到这个?

sql-server sql-server-2008 sql-server-2012 sql-server-2008-r2
1个回答
0
投票

当你说“组合#8”时,你实际上只是指服务器3 +许可证1?像这样的东西?

declare @daycount int
select @daycount = count(distinct [date]) from table1

select ServerID, LicenseID
from table1
group by ServerID, LicenseID
having count(*) != @daycount
© www.soinside.com 2019 - 2024. All rights reserved.