答案 0 :(得分:2)
尝试此查询:
SELECT respond_id, incident_id, pnt_id FROM TBL
WHERE pnt_id IS NOT NULL
UNION
SELECT respond_id, incident_id, pnt_id FROM TBL
WHERE incident_id in (SELECT distinct(incident_id)
FROM TBL
GROUP BY incident_id
HAVING count(id) = 1);
union的第一部分将获得所有not null pnt_ids 第二部分将获取所有可能为null的记录,但会输入结果。
Union合并两个结果,消除重复