I am new to SQL so this may be a very common/easy question, I want to order these from highest to lowest rather than Team 1, Team 2, Team 3. See below:
SQL
Select (select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '1' and W.Activity = '2' ) AS Team1,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '2' and W.Activity = '2' ) AS Team2,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '3' and W.Activity = '2' ) AS Team3,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '4' and W.Activity = '2' ) AS Team4,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '5' and W.Activity = '2' ) AS Team5,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '6' and W.Activity = '2' ) AS Team6,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '7' and W.Activity = '2' ) AS Team7,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '8' and W.Activity = '2' ) AS Team8,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '9' and W.Activity = '2' ) AS Team9,
(select SUM(Amt) from Tracker W JOIN Teams T ON W.Username = T.Name where T.Team = '10' and W.Activity = '2' ) AS Team10
Right now the result shows like this:
I want it to show highest to lowest rather than by team name. Can this be done with an Order By? I just can't seem to get it to work.
Team 2 - 597, Team 7 - 540, Team 3 - 467, etc.