If I have a table like
task_id | state
--------+------------
1 | NULL
--------+------------
1 | RESOLVED
--------+------------
2 | NULL
--
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
Try this -
SELECT task_id
FROM YOUR_TABLE
WHERE state NOT IN (SELECT task_id
FROM YOUR_TABLE
WHERE task_id IS NOT NULL)
here is my approach :
Select * from yourTable where state is null and task_id not in
(select task_id from yourTable y where state is not null )
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