sqlserver查询数据表中每个分类最新的一条记录
SELECT t1.*
FROM PKappa t1,
(SELECT CategoryId,
MAX(ExaminationTime) ExaminationTime
FROM PKappa
WHERE EmployeeNo='A0086875'
GROUP BY CategoryId) t2
WHERE t1.ExaminationTime=t2.ExaminationTime
AND t1.CategoryId=t2.CategoryId
AND EmployeeNo='A0086875' AND
t1.ExaminationTime>='2020-04-16 00:00:00.000'
ORDER BY CategoryId