Joining to MAX date record in group

前端 未结 3 1756
耶瑟儿~
耶瑟儿~ 2020-12-14 06:06
Job
--------
Id
Description


JobStatus
----------
Id
JobId
StatusTypeId
Date

How do I get the current JobStatus for all jobs?

3条回答
  •  别那么骄傲
    2020-12-14 06:50

    Another (not very efficient, but easy to understand) solution for SQL Server 2000:--

    SELECT  *
    FROM    job j
    WHERE   j.date = (SELECT MAX(date) 
                      FROM   job 
                      WHERE  id = j.id)
    

提交回复
热议问题