我使用聚合函数“SUM”编写了以下查询。
SELECT
D.PODetailID,
SUM(D.AcceptedQty)
FROM STR_MRVDetail D
INNER JOIN STR_MRVHeader H ON H.MRVID = D.MRVID
INNER JOIN PUR_POHeader PH ON PH.POID = H.POID
INNER JOIN PUR_PODetail PD ON PD.PODetailID = D.PODetailID
WHERE H.StatusID = 4
AND PH.POID = 839
AND (SELECT
SUM(AcceptedQty)
FROM
STR_MRVDetail
WHERE
STR_MRVDetail.PODetailID = PD.PODetailID) =
(SELECT POQuantity FROM PUR_PODetail
WHERE PUR_PODetail.PODetailID = PD.PODetailID)
GROUP BY D.PODetailID
目前,此查询返回 2 行。我想检索此查询的计数。如何计算上述查询的行数?