- 作用
為group by分組指定條件,篩選出想要的分組。而where是篩選出想要的行。
- 書寫順序
select from where group by having
- 聚合健所對應(yīng)的條件不應(yīng)該書寫在having子句中,雖然也能寫,但最好寫在where子句中。因?yàn)閳?zhí)行速度要快,第二個原因是條件放在where子句中,可以對指定條件的列創(chuàng)建索引來加快查詢
為group by分組指定條件,篩選出想要的分組。而where是篩選出想要的行。
select from where group by having