我试图计算加密或拒绝加密或拒绝加密的次数, 在一个特定栏栏中出现。 下面的代码返回有问题
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为什么要这么做吗?