I have a result set in generated as CTE using Union that contains duplicate records. as in image below:
And the query is:
WITH CTE (StartTime ,EndTime )
AS
(
SELECT StartTime ,EndTime, Null as Exclude, SupplierId FROM cms.TimeSlotMaster
WHERE Monday = 1 AND SupplierID IS NULL
UNION
SELECT StartTime ,EndTime FROM cms.TimeSlotOverRider
WHERE SupplierID IS NULL
AND StartDate <= cast(GETDATE() as DATE) AND EndDate >= cast(GETDATE() as DATE)
)
Now I am trying to remove the duplicate results from this result set at all. So finally the results set should be only 2 rows. So it should look like below:
Any help would be appreciated. Thanks.
For more information the first result set is generated using below CTE