1. 程式人生 > >Unknown column 's.score' in 'having clause' 0.00020 sec error

Unknown column 's.score' in 'having clause' 0.00020 sec error

SELECT
    s.name
FROM
    student AS s
GROUP BY s.name

HAVING s.score > 80;

因為having 後面只能跟聚合函式所以這樣寫是錯誤的。 但是把having改成 where放到group by 後面也是不對的。可以把where和group by換個位置就可以了。。

SELECT
    s.name
FROM
    student AS s
WHERE
    s.score > 80
GROUP BY s.name;