Re: Query criteria
- From: "ladybug via AccessMonster.com" <u21071@uwe>
- Date: Tue, 25 Mar 2008 18:34:09 GMT
What you gave me worked as far as showing me which status_id(s) has the most
recent date. However, there may be two entries entered on the same date. I
need to know which one out of the two were added last.
For example, this is what is returned with what you gave me:
status_id lif_id status_dt status
103 1390 03/25/08 open
104 1390 03/25/08 closed
I want it to only return entry 104 because it is the most recent date and it
was the last one entered for that date. Does that make sense? Sorry, if I
was unclear before. Thank you so much for your help!
John Spencer wrote:
SELECT tbl_Status.Lif_id, tbl_status.Status_dt
, tbl_Status.Status
FROM tbl_Status INNER JOIN
(SELECT Lif_ID, Max(Status_Dt) as LastDate
FROM tbl_Status
GROUP BY Lif_ID) as Tmp
ON tbl_Status.Lif_Id = Tmp.Lif_Id
and tbl_Status.Status_dt = Tmp.LastDate
I don't understand what you mean here
"if there is more than one entry on that date return the
status with the higher lif_id. "
There may be more than one record for any one date and Lif_id, but the
Lif_ID will always be equal to itself. So this cannot be used to
discriminate to get a higher value. Did you mean to refer to another field
as the tie breaker?
I have a table called tbl_status. In this table there are 7 fields.[quoted text clipped - 11 lines]
status_id Autonumber
I have no idea how to do this in a query. Can someone help me?
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200803/1
.
- Follow-Ups:
- Re: Query criteria
- From: John Spencer
- Re: Query criteria
- References:
- Query criteria
- From: ladybug via AccessMonster.com
- Re: Query criteria
- From: John Spencer
- Query criteria
- Prev by Date: Re: Update query problem
- Next by Date: Re: Current month in the criteria of a query
- Previous by thread: Re: Query criteria
- Next by thread: Re: Query criteria
- Index(es):
Relevant Pages
|