下面是我的查询,但我的 SQL 似乎不正确。基本上我试图让第 7 列显示来自单独表 (C) 的计数,但我收到错误。有什么帮助吗?查询工作正常,没有 select 语句中的第二个计数,但我只是试图让第 7 列获得另一个表的计数。
select
distinct a.auditid,
a.iav,
c.VID as 'VMS ID',
c.severity as 'VMS Severity',
a.name,
count (distinct A.dnsname) as 'cat 1s',
count (distinct c.dnsname) as 'ccri'
from
[dbo].[Enterprise 20130703] a
left join [dbo].[VMS_Retina] c on a.AuditID=c.auditid
inner join [CCRI 2013] c on a.dnsname=c.DNSName
where
A.sevcode = 'category i'
AND A.DNSNAME NOT IN ('autodiscovery,'UNKNOWN')
group by A.auditid, a.iav, a.name, c.VID, c.severity
order by 6 desc