sql - Access - Selecting unique rows with newest date -
i have access database table track assignments between laptops , vehicles called records, shows computername, unitnumber it's assigned to, , date assignment recorded.
id computername unitnumber daterecorded 1 lt150 5010 8/1/2015 2 lt150 788 8/30/2015 3 lt235 4009 8/4/2015 4 lt150 123 9/21/2015
now i'm trying find way query results show unique computername recent daterecorded.
so results be
computername unitnumber daterecorded lt150 123 9/21/2015 lt235 4009 8/4/2015
i can't figure out how make query work. tried, gives me aggregate function error.
select computername, max(daterecorded) recetdate, unitnumber records group computername
you don't use group by
type of query.
instead:
select r.* records r r.daterecorded = (select max(r2.daterecorded) records r2 r2.computername = r.computername );
note: assumes same date not used twice same computer.
Comments
Post a Comment