有些人能否帮助我指出以下T-SQL syntax有什么错误?
SELECT
p.CompanyId, COUNT(*) as PolicyCount, c.CompanyId, c.CompanyName
FROM
dbo.Policy p
INNER JOIN dbo.Company c ON p.CompanyId = c.CompanyId
WHERE
p.PolicyIssuingDate BETWEEN @StartDate AND @EndDate
GROUP BY
p.PolicyId
I keep getting the following syntax error:
Column dbo.Policy.Company 选择清单中Id是无效的,因为清单不包含在按条款分列的总职能或组别中。
任何建议?
<><>UPDATE:
由于你的投入,我将其说出来...... 解决办法:
SELECT
p.CompanyId, COUNT(p.PolicyId) as PolicyCount, c.CompanyName
FROM
dbo.Policy p
INNER JOIN dbo.Company c ON p.CompanyId = c.CompanyId
WHERE
p.PolicyIssuingDate BETWEEN @StartDate AND @EndDate
GROUP BY
p.CompanyId, c.CompanyName