Thank you very much for your prompt answer.
Here are the items:
Tables:
CaseMaster
CaseEvents
Fields:
From Case Master:
CaseNumber
CaseContact
CaseOpenDate
From CaseEvents:
EventDescription
EventDate
I grouped everything and use Max on the EventDate and Group By on all the
other fields but the query still return ALL events per case.
Let me know what I am doing wrong.
Thank you.
Brigham
Dear Brig:
It is certain that the query will return all the values of columns you GROUP
BY. You only want to GROUP BY those columns that determine a level of
summary.
The point is, you cannot return any columns that are not in the GROU)P BY or
in the aggregate. That is, not in an aggregate query. So, you do not want
an aggregate query.
Rather, try this:
SELECT M.CaseNumber, M.CaseContact, M.CaseOpenDate
E.EventDescription, E.EventDate
FROM CaseMaster M
INNER JOIN CaseEvents E
ON E.CaseNumber = M.CaseNumber
WHERE E.EventDate =
(SELECT MAX(E1.EventDate)
FROM EventDate E1
WHERE E1.CaseNumber = M.CaseNumber)
You did not show it, but surely the CaseEvents table has a CaseNumber
column, right?
Except for this question, I believe the above is your solution. No GROUP BY
involved, just filtering.
Tom Ellison
> Thank you very much for your prompt answer.
>
[quoted text clipped - 61 lines]
>> >
>> > Brigham
Brig Siton - 02 May 2006 14:09 GMT
Thanks Tom. I got it. it worked.
> Dear Brig:
>
[quoted text clipped - 91 lines]
> >> >
> >> > Brigham