Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Obtenir les meilleurs enregistrements 'n' par report_id

Que diriez-vous

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