以下查询返回RowNumber_ps = 101
,RowNumber_ps
是行计数,但是它应该返回RowNumber_ps = 1
,因为我只有一行包含0个文档。任何人都可以告诉我RowNumber_ps
没有返回1的查询有什么问题吗?
SELECT *
FROM
(SELECT
ROW_NUMBER() OVER(Order By ParentID) AS RowNumber_ps,
UPPER(HostApplicationLocalData.ParentID) asParentID,
COUNT(Document.ID) AS Documents
FROM
HostApplicationLocalData
LEFT OUTER JOIN
Document ON HostApplicationLocalData.ID = Document.HostApplicationLocalData_ID
WHERE
HostApplicationLocalData.TransactionType_ID = 1
AND HostApplicationLocalData.Company_ID = 9000
GROUP BY
HostApplicationLocalData.ParentID) q
WHERE
Documents = '0'
答案 0 :(得分:-1)
您应该在子查询中放置'WHERE'条件。