I have a table that looks like this:
Table Name: upAssoc
k p f
1 3 80
2 3 50
3 1 2
4 2 8
5 1 22
What I want to do is:
Combine all the columns with the same number in P
SUM the F column
Order them by highest to lowest in descending order based on the sum of F.
So basically I want this output:
3 130 //80 + 50 (F column)
1 22 // next largest number
2 8 // next..
1 2 // smallest
How do I write this query in a single line?