我當前的查詢如下:如何將HAVING和GROUP BY組合到同一個SQL中?
SELECT user_id, sum(...) as total from mytable
group by user_id
工作正常
然而,當我嘗試
SELECT user_id, sum(...) as total from mytable
group by user_id
having total >= 10
我得到一個錯誤
SELECT user_id, sum(...) as total from mytable
having total >= 10
工作正常。我如何結合HAVING和GROUP BY?
你會得到什麼錯誤?運行所有三個查詢都適用於我,我只是得到不同的結果集。 – BoltClock 2011-02-25 11:55:40
'@deltanovember:'你使用哪個數據庫? – Wowa 2011-02-25 12:57:52