I want a query to identify the Vehicle Registration Numbers
having more than 1 policy with different Insurance Company ID
, with overlapping dates. Check this image for the datas
SELECT Vehicle_N0.*
FROM excel as Vehicle_N0
WHERE Vehicle_N0 IN (SELECT Vehicle_N0
FROM excel
GROUP BY Vehicle_N0
HAVING COUNT(DISTINCT Insurance_id) > 1)
ORDER BY vehicle_n0
using this query i got the Vehicle Registration Numbers
having more than 1 policy with different Insurance Company ID
but how to get the overlapping dates.
I tried this query
SELECT *
FROM excel
WHERE begin_date <= end_date
OR begin_date >= end_date;
But i didn't get the overlapped dates.