sql server select top 2 of each group

Solutions on MaxInterview for sql server select top 2 of each group by the best coders in the world

showing results for - "sql server select top 2 of each group"
Alya
29 Mar 2018
1SELECT * FROM 
2(
3SELECT column1, 
4column2,
5cloumn3, 
6row_number() over (PARTITION BY ColumnToGroupBy ORDER BY ColumnToOrderBy DESC) AS TempColumnName
7FROM cities
8) AS TempTableName
9WHERE TempTableName <= 2
10