Using an aggregate function in where

后端 未结 2 1997
故里飘歌
故里飘歌 2021-01-18 09:21

I saw a few threads here with similar questions however I couldn\'t find something fitting my needs.

Consider the following table and example data:

CRE         


        
2条回答
  •  無奈伤痛
    2021-01-18 09:52

    You can't use aggregate expression in the where clause - this is what the having clause is for:

    SELECT   a, SUM(b)
    FROM     foo
    GROUP BY a
    HAVING   SUM(b) > 9
    

提交回复
热议问题