这是我的查询
select narr,vocno,count(*)
from KontenLedger
WHERE VOCDT>'2018-07-01'
group by narr,vocno
having count(*)<'3'
实际上,如果我像上面给出的那样怀特,如果我删除字段(“ narr”)的答案,计算两个字段(“ narr”和“ vocno”)的结果是正确的。我还需要查看“ narr”字段,而无需计算
答案 0 :(得分:1)
不了解您的数据库,没有有限的采样日期,也没有预期的输出?
SELECT
vocno,
COUNT(*) AS total,
MAX(narr) AS max_narr
FROM KontenLedger
WHERE vocdt > '2018-07-01'
GROUP BY vocno
HAVING COUNT(*) < 3