Hide Duplicates

Charmed7

Registered User.
Local time
Today, 09:00
Joined
Jul 23, 2004
Messages
53
Goal - Show how many policies (dbo_Policy22.Policy.Number) were cancelled during a certain time period (Invoice Date).

Problem - a policy can be cancelled more than once and I don't want to count it after the initial cancel status (885).

Question - Below is my query. I'm thinking I type "Distinct" somewhere, but I have no idea where.

Please help :) Thank you.

SELECT dbo_Producer22.Number, dbo_Producer22.Name, dbo_Invoice22.Invoice_Date, dbo_Policy22.POLICY_STATUS, dbo_Policy22.Policy_Number
FROM dbo_Producer22 INNER JOIN ((dbo_Insured22 INNER JOIN dbo_Invoice22 ON dbo_Insured22.Insured_Key = dbo_Invoice22.Insured_Key) INNER JOIN dbo_Policy22 ON dbo_Insured22.Insured_Key = dbo_Policy22.Insured_Key) ON dbo_Producer22.Producer_Key = dbo_Policy22.Producer_Key
GROUP BY dbo_Producer22.Number, dbo_Producer22.Name, dbo_Invoice22.Invoice_Date, dbo_Policy22.POLICY_STATUS, dbo_Policy22.Policy_Number
HAVING (((dbo_Invoice22.Invoice_Date) Between [Forms]![PfrmYearToDate]![txtStartDate] And [Forms]![PfrmYearToDate]![txtEndDate]) AND ((dbo_Policy22.POLICY_STATUS)=885));
 
Not-So-Quick Fix.

I think my above goal isn't going to work because of the dates being different for each cancellation. So I just ran another query after the date parameter is made to remove the duplicates and then run my count query off of that. <sigh> I'm getting so lost in my own database.
 
Create a totals query that returns only the data that will be identical in duplicate records, plus the date. Set the aggregate function to MIN on the date and this will return only the first instance of the cancellation. Then base your other query on that that query.
 

Users who are viewing this thread

Back
Top Bottom