我正在尝试计算 Encrypted 或 Denied 出现在某个列中的次数。下面的代码返回没有问题
use DEW
SELECT Count (distinct DeviceData.machinename) As [Number Of Devices],
DeviceData.CurrentSite, DeviceData.Country
,sum(case buildstatus when 'encrypted' then 1 else 0 end) encrypted
,sum(case buildstatus when 'Denied' then 1 else 0 end) Denied
FROM dbo.DeviceData
where currentsite = 'REN'
group by DeviceData.Country, CurrentSite
输出是这样的:
Number of Devices SiteCode Country Encrypted Denied
3 REN Greece 0 3
但是,当我添加内部联接时
FROM dbo.DeviceData JOIN dbo.SiteList ON dbo.DeviceData.country = dbo.SiteList.Country
拒绝更改的数量为 33。
知道为什么 SQL 会这样做吗?