日期:2014-05-17 浏览次数:20557 次
SELECT
a.logoid,
a.trainingoid,
a.employeeoid,
a.lastDate,
a.nextDueDate,
a.fileName
FROM dbo.OPERATOR_SOP_LOG_ENTRY AS a
INNER JOIN
(SELECT
trainingoid,
employeeoid,
MAX(lastDate) AS mdate
FROM dbo.OPERATOR_SOP_LOG_ENTRY
GROUP BY trainingoid, employeeoid) AS b
ON a.trainingoid = b.trainingoid AND a.lastDate = b.mdate
--取lastdate =按照trainingold和employeeoid分组后最大日期的相应数据
SELECT a.logoid ,
a.trainingoid ,
a.employeeoid ,
a.lastDate ,
a.nextDueDate ,
a.fileName
FROM dbo.OPERATOR_SOP_LOG_ENTRY AS a
INNER JOIN ( SELECT trainingoid ,
employeeoid ,
MAX(lastDate) AS mdate
FROM dbo.OPERATOR_SOP_LOG_ENTRY
GROUP BY trainingoid ,
employeeoid
) AS b ON a.trainingoid = b.trainingoid
AND a.lastDate = b.mdate