前不久刚写过一个类似的
select * from your_table
where crd_no in (
select crd_no from (
SELECT aa.crd_no as crd_no, count(aa.crd_no) as dup_count
FROM your_table aa, your_table bb
WHERE aa.crd_no = bb.crd_no
AND aa.id <> bb.id
AND ( (aa.start_date between bb.start_date and bb.end_date)
OR (bb.start_date between aa.start_date and aa.end_date)
)
group by aa.crd_no having count(aa.crd_no) < 3
)
)
大文字的是我写的用来check重复纪录的,小文字是根据LZ要求加的,没测试过,LZ自己测一下吧