The Sanctuary
Technology => Technophiliacs & Technophiles => Topic started by: theKit on October 11, 2014, 03:44:17 am
-
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?
-
I need to stop trying to code late at night, thanks for all the help you retards this one was simple
SELECT p, SUM(f) FROM upAssoc GROUP BY f DESC;
-
And we're the retards...
-
I probably could have got it if I saw it in time. I'm not much for SQL, but I did play around with it a little bit.
I actually want to get back to learning soon. SQL injection especially. Maybe I'll get fired soon... ;)