0

I have the following table and I would like for each of the items in col1 to get the rows that have the top N (for example 10) highest/largest values

    col1    col2    value
    item1   item2    3
    item1   item3    2
    item1   item4    1
    item2   item3    2 
    item2   item1    3
    item2   item4    1

The result would be the following table if we took the top 2:

    col1    col2    value
    item1   item2    3
    item1   item3    2
    item2   item1    3
    item2   item3    2

How would this be done in SQL (postgress)

Mustard Tiger
  • 3,191
  • 8
  • 36
  • 60

0 Answers0