I wrote this query:
SELECT MAX(effectivedate) as MaxEffectiveDate, AccountId, RTRIM(codeStatus.Description) as Status
FROM PlcPolicy plc
JOIN dbo.CodePlcStatus codeStatus WITH (NOLOCK) ON codeStatus.StatusId = plc.StatusId
WHERE AccountName LIKE 'Hertz%'
GROUP BY AccountId, RTRIM(codeStatus.Description)
I want to return the the record with the highest effective date for each accountid.
Here the results from the query. As you can see it doesn't pull the highest date. It should only give me one row with the effective date '2021-07-01' if I'm pulling MAX but it still gives me 2??