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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -