I have one table that has multiple id's and associated dates as well as other fields. I would like to query all the id's with the id's latest date entry and include other fields in this query. The following query selects the one id value and its latest date entry:
SELECT id, MAX(InspectionDt)
FROM table
GROUP BY ID
As I said I would also like to include other fields from this same table in my query which I tried using this query:
select *
from table t1
inner join
(SELECT id, MAX(InspectionDt) As inspectiondt
FROM table
GROUP BY ID) t2 on t1.ID = t2.ID
But I end up with duplicate id values which I dont want.
What query accomplishes this?
Thanks in advance.
SELECT id, MAX(InspectionDt)
FROM table
GROUP BY ID
As I said I would also like to include other fields from this same table in my query which I tried using this query:
select *
from table t1
inner join
(SELECT id, MAX(InspectionDt) As inspectiondt
FROM table
GROUP BY ID) t2 on t1.ID = t2.ID
But I end up with duplicate id values which I dont want.
What query accomplishes this?
Thanks in advance.