I wish I could solve this on my own but I tried searching and googling but nothing doing.
Althought worse comes to worse, I can use Perl to do what I want, but I would prefer having a SQL syntax that can handle it.
3 columns: username, daily units, rare units.
I need to add daily units + rare units , group them by username, and then order it by the sum of daily units and rare units.
username | daily units | rare units
bobby1 ........ 100 ........ 200
bobby2 ........ 200 ........ 300
bobby3 ........ 300 ........ 400
Table results should be:
username | total units
bobby3 ........ 700
bobby2 ........ 500
bobby1 ........ 300
I'm sure there is a way to do it but I can't seem to figure it out.
SELECT username, SUM(daily_units, rare_units) FROM table GROUP BY username ORDER BY SUM(daily_units, rare_units)
^ gave error obv.
I also tried other lil syntax, but keep getting no results!!
I can have Perl store this table inside a hash, and figure out the rankings that way, but SQL syntax would avoid all the extra perl coding needed.
Thanks for taking your time to read this post.