AnnieRider
MIS
I am trying to return just the latest entry from a History Table but I need to link it to a details table so that it just selects the latest history for certain people.
I have tried
Select Org_Ref, max(CR_HISTORY.Client_Ref) AS "SG"
From CR_HISTORY Inner Join CR_CLIENTS on CR_HISTORY.Client_Ref = CR_CLIENTS.Client_Ref
Where Left(CR_CLIENTS.Card_Ref,2) In ('11','12')
AND CR_HISTORY.HistoryType_Ref = 'E' AND CR_HISTORY.DateStart > '20110101'
Group By CR_HISTORY.Client_Ref, Org_Ref
But I am getting more than one entry for a Client_Ref when I just want the latest.
Thanks
Annie
I have tried
Select Org_Ref, max(CR_HISTORY.Client_Ref) AS "SG"
From CR_HISTORY Inner Join CR_CLIENTS on CR_HISTORY.Client_Ref = CR_CLIENTS.Client_Ref
Where Left(CR_CLIENTS.Card_Ref,2) In ('11','12')
AND CR_HISTORY.HistoryType_Ref = 'E' AND CR_HISTORY.DateStart > '20110101'
Group By CR_HISTORY.Client_Ref, Org_Ref
But I am getting more than one entry for a Client_Ref when I just want the latest.
Thanks
Annie