现有表如下:
需要查询每一个item对应的最后一条数据,SQL SERVER 如下:
SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY ItemCode ORDER BY RecordID desc) as RowNum, * from RSItemCostChange ) as H where H.RowNum = 1 ORDER BY ItemCode
标签:每组,查询,SQL,RowNum,SERVER,ORDER,SELECT From: https://www.cnblogs.com/nanbai/p/17295713.html