date - Find most recent result in query - ms access -
i have access database, trying determine recent result in query. want know whether recent loan item complete or not. e.g.
tbl_loans
loanid equipment number start date return date expr:isonloan 123 78457 16/05/2001 19/06/2003 loan complete 124 79557 17/07/2016 loan in progress 125 78457 03/06/2016 loan in progress 126 79630 01/01/2015 01/01/2016 loan complete 127 79360 02/03/2016 loan in progress 128 78457 01/01/2016 01/03/2016 loan complete
where expr:isonloan iif:
isonloan: iif([loans]![return date] null,"loan active","loan complete")
i return recent result each equipment number in column in query (probably separate query) i.e.
loan id equipment number start date return date expr:isonloan 125 78457 03/06/2016 loan in progress 127 79360 02/03/2016 loan in progress 128 78457 01/01/2016 01/03/2016 loan complete
microsoft's support pages have me use 'top' others i've seen have used inner join , can't either of them work.
any appreciated
thanks
one way handle use inner join
between tbl_loans
table , subquery identifies recent dates each equipment number.
select t1.loanid, t1.[equipment number], t1.[start date], t1.[return date], t1.[expr:isonloan] tbl_loans t1 inner join ( select [equipment number], max([start date]) [start date] tbl_loans group [equipment number] ) t2 on t1.[equipment number] = t2.[equipment number] , t1.[start date] = t2.[start date]
Comments
Post a Comment