I have a database with medical/dental claims in it. I'm trying to create a SQL query that wil look at all the claims in the past week (for example) and then find any claims in the past 6 months (also for example) that might potentially be a duplicate. By duplicate I mean that the member ID is the same, the procedure code is the same, the provider (doctor) is the same and the claim dollar amount is the same.
I'm having trouble with this and am ending up creating an infinite loop of sorts where I get every claim joined to every other claim.
Any guidance on this would be greatly appreciated...
Basically the table I'm querying has columns (that I'm interested in of the form):
Date_of_service, member_id, claim_number, provider_id, diagnosis_code, claim_amount