Data Science, Python, Pandas.
integers (starting with 1 for every partitioned subset): SELECT row_number() OVER ( PARTITION BY article ORDER BY n DESC ) ArticleNR, article, coming_from, n FROM article_sum Then we aggregate the rows again by the article column and return only those with the index equal to 1, essentially