我已经构建了这个 SQL 查询,它搜索所有保单号码并返回所有多个 PPOLNO 货币值的总和:
SELECT PPOLNO, SUM(PPRMPD) AS SUM
FROM PFNTLPYMTH
WHERE SUM(PPRMPD) >= 5000
AND ((PYEAR=2012 AND PMONTH >=3
AND PDAY >=27) OR (PYEAR=2013
AND PYEAR <=3 AND PDAY<=27))
GROUP BY PPOLNO
我正在寻找的只是在 SUM >= 特定值时才返回它们。这可能吗?如何?我试过这个:
SELECT PPOLNO, SUM(PPRMPD) AS SUM FROM PFNTLPYMTH
WHERE SUM(PPRMPD) >= 5000 AND ((PYEAR=2012 AND PMONTH >=3 AND PDAY >=27) OR (PYEAR=2013
AND PYEAR <=3 AND PDAY<=27)) GROUP BY PPOLNO
但无济于事。我也刚刚尝试输入 WHERE SUM >= 5000,但同样没有。
任何帮助将不胜感激。
- 乔什