1. select * from( select row_number() over(partition by Product_PromotionId order by AutoId desc)as rowindex,* from dbo.Order_Product_Promotion_Details) a where rowindex<6 2. select * from dbo.Order_Product_Promotion_Details t where AutoId in(select top 5 AutoId from dbo.Order_Product_Promotion_Details where Product_PromotionId=t.Product_PromotionId AND State=2 AND BeginDate<GETDATE() AND EndDate>GETDATE() order by AutoId desc)
sql 每个分类取最新的几条数据
猜你喜欢
转载自vtrtbb.iteye.com/blog/1757107
今日推荐
周排行