我有以下查询。
step2
然后我想过滤掉NumResults,因此该表仅显示NumResults = 1的结果。
答案 0 :(得分:2)
使用HAVING
子句过滤聚合函数的结果(在您的情况下为COUNT
)
SELECT COUNT(id) AS NumResults, race_date AS RaceDate, race_time AS RaceTime
FROM results
WHere jockeys_claim = 10
GROUP BY race_date, race_time
HAVING COUNT(id) = 1
ORDER BY race_date DESC, race_time ASC