📜  sql server 选择每个组的前 2 个 - SQL 代码示例

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

代码示例1
SELECT * FROM 
(
SELECT column1, 
column2,
cloumn3, 
row_number() over (PARTITION BY ColumnToGroupBy ORDER BY ColumnToOrderBy DESC) AS TempColumnName
FROM cities
) AS TempTableName
WHERE TempTableName <= 2