Which SQL statement is faster? (HAVING vs. WHERE…)

后端 未结 8 1602
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 20:18
SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
    FROM  PRACOWNICY
    GROUP BY NR_DZIALU
    HAVING NR_DZIALU = 30

or

SE         


        
8条回答
  •  盖世英雄少女心
    2020-12-02 20:41

    "Having" is slower if we compare with large amount of data because it works on group of records and "WHERE" works on number of rows..

    "Where" restricts results before bringing all rows and 'Having" restricts results after bringing all the rows

提交回复
热议问题