Try
;with cte as (select *, COUNT(Date_Of_Service) OVER (partition by CustomerID, LOB) as cntVisits from myTable
WHERE Date_Of_Service >=dateadd(day,-180+datediff(day, '19000101', CURRENT_TIMESTAMP), '19000101'))
SELECT * from cte
WHERE cntVisits >1 -- same customer visited the same location more than once
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles
No comments:
Post a Comment