在商品申请表中有很多条记录,只是主键和记录的状态和创建时间不同,如何根据ProductId和CoursewareId,找出日期最近的相关记录
SELECT * FROM dbo.E_ProductApplication AS t1
WHERE CreateDate IN
(
SELECT MAX(CreateDate)
FROM dbo.E_ProductApplication AS t2
WHERE t1.ProductId=t2.ProductId
AND t1.CoursewareId=t2.CoursewareId
)
SELECT * FROM dbo.E_ProductApplication AS t1
WHERE CreateDate IN
(
SELECT MAX(CreateDate)
FROM dbo.E_ProductApplication AS t2
WHERE t1.ProductId=t2.ProductId
AND t1.CoursewareId=t2.CoursewareId
)