Answers for "sql server select top 2 of each group"

SQL
0

sql server select top 2 of each group

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
Posted by: Guest on July-26-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language