📜  sql server 选择具有最大 id 的记录 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:20.347000             🧑  作者: Mango

代码示例1
select ID , ProductCatId , ProductCode , Price
  from (
        select ID , ProductCatId , ProductCode , Price, row_number() over (partition by ProductCatId order by ID desc) as rn
         from myTable
        ) as t
  where t.rn = 1