我遇到以下情况的麻烦:
答案 0 :(得分:2)
您可以使用distinct on
保留一行:
select distinct on (task_id, date) t.*
from t
order by task_id, date, finish_time nulls last;
答案 1 :(得分:1)
delete from t
where id IN
(select distinct on (task_id, date) t.id
from t
order by task_id, date, finish_time nulls last) as sub