Job
--------
Id
Description
JobStatus
----------
Id
JobId
StatusTypeId
Date
How do I get the current JobStatus for all jobs?
so something like….
SELECT * FROM Job j
INNER JOIN ( /* Select rows with MAX(Date) grouped by JobId */ ) s
ON j.Id = s.JobId
(I’m sure there are a bunch of similar questions already but I couldn’t find anything which exactly does what I need).
In
SQL Server 2005+:In
SQL Server 2000:These queries handle possible duplicates on
Datecorrectly.