hi,
i have a table( tblUpdate) with the following fields
UpdateID, UpdateDate, ActionID
UpdateID is the primary key
ActionID is a foreign key
i want to find the latest (by date) update of a particluar action.
and i can do this using the following:
SELECT Max(tblUpdate.UpdateDate) AS MaxOfUpdateDate, tblUpdate.ActionID
FROM tblUpdate
GROUP BY tblUpdate.ActionID;
this gives me :
"MaxOfUpdateDate","ActionID"
24/9/2005 ,24
26/8/2005 ,25
11/9/2005 ,26
26/9/2005 ,28
which is good but i also need the primary key, UpdateID
If i add updateID into the query i get
SELECT Max(tblUpdate.UpdateDate) AS MaxOfUpdateDate, tblUpdate.UpdateID,
tblUpdate.ActionID
FROM tblUpdate
GROUP BY tblUpdate.UpdateID, tblUpdate.ActionID;
i now get this
"MaxOfUpdateDate","ActionID","UpdateID"
24/9/2005 ,24,23
22/9/2005 ,24,24
26/8/2005 ,25,25
26/9/2004 ,25,26
11/9/2005 ,26,27
26/9/2005 ,28,28
which is no good because im getting results for all the updateids
i really just want :
"MaxOfUpdateDate","ActionID"
24/9/2005 ,24
26/8/2005 ,25
11/9/2005 ,26
26/9/2005 ,28
but with the primary key for each one.
any help would be much appreciated
thanks in advance
jim


|