sql >> Base de Datos >  >> RDS >> Sqlserver

Obtener registros top 'n' por report_id

¿Qué tal

SELECT *
FROM (SELECT *,
         ROW_NUMBER() OVER(PARTITION BY report_id ORDER BY (SELECT 0)) AS RN
         FROM top_keywords
         WHERE ym BETWEEN '2010-05' AND '2010-05') TK
WHERE RN <= 10