How to select grouped rows with only NULL values?

前端 未结 4 1164
一生所求
一生所求 2021-01-24 16:15

If I have a table like

task_id | state
--------+------------ 
   1    |  NULL
--------+------------
   1    |  RESOLVED
--------+------------
   2    |  NULL
--         


        
4条回答
  •  野性不改
    2021-01-24 17:06

    As COUNT function ignores NULL in case a specific column is assigned, you can use group by, count and having as below.

    SELECT task_id
    FROM t1
    GROUP BY task_id
    HAVING count(STATE) = 0;
    

    DEMO

提交回复
热议问题