select sex,count(*) from table where count(*)>5
報錯
sql語句的執行過程是:
from-->where-->group by -->having --> select--- >order by;
聚合函數針對結果集,where並不是在結果集后運行。
having針對結果集,把聚合函數放在having之后。
select sex,count(*) from table having count(*)>5
select sex,count(*) from table where count(*)>5
報錯
sql語句的執行過程是:
from-->where-->group by -->having --> select--- >order by;
聚合函數針對結果集,where並不是在結果集后運行。
having針對結果集,把聚合函數放在having之后。
select sex,count(*) from table having count(*)>5
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。