How to select grouped rows with only NULL values?

前端 未结 4 1168
一生所求
一生所求 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:19

    Do a GROUP BY, use HAVING to return task_id having only null states.

    select task_id
    from tablename
    group by task_id
    having max(state) is null
    

提交回复
热议问题