Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql top 3 for each group

SELECT a.field1, a.field2
    FROM (
      SELECT field1, field2, ROW_NUMBER() --use RANK() if you want ranking
      over (Partition BY field_partition
            ORDER BY data_field DESC ) AS Rank
      FROM your_table
    ) a WHERE Rank <= 3 --Row Number you want of each group
 
PREVIOUS NEXT
Tagged: #sql #top #group
ADD COMMENT
Topic
Name
9+2 =