sorting - SQL sort based on sum of various columns -
i have ms-sql table of game results contains home team, home team score, away team, , away team score. attempting query teams, wins, , losses ordered first, total wins(descending) , total losses(ascending). table does not contain wins or losses column. wins , losses must calculated based on score. if need create view or temporary table, how create view teams, wins, , losses?
select * mytable ... order sum(win) desc, sum(loss) asc for more detailed answer, provide schema , sample data.
Comments
Post a Comment