标签: sql oracle
现在我们需要一个SQL查询来获取状态为(failed,null)的记录,并重试计数< 10.显然最终结果应包含id = 1,2,3但不包含4
答案 0 :(得分:3)
您需要join并注意NULL值:
join
NULL
select a.id from tableA a left join tableB b on a.id = b.id where (a.status is null or a.status = 'FAILED') and coalesce(b.retrycount, 0) < 10;