Hi All,
I have a table with wins and losses. When I select the data I would like to calculate pct (win percentage) and gb (games behind).
My schema is table SCRECORDS, fields: NAME (varchar), WINS(int), LOSSES(int)
I found a query like this but it seems broken.
Thanks!
I have a table with wins and losses. When I select the data I would like to calculate pct (win percentage) and gb (games behind).
My schema is table SCRECORDS, fields: NAME (varchar), WINS(int), LOSSES(int)
I found a query like this but it seems broken.
Code:
SELECT @wl_diff = MAX(WINS-LOSSES) FROM SCRECORDS;
SELECT NAME, WINS AS W, LOSSES AS L, WIN(WINS+LOSSES) AS PCT,
(@wl_diff - (WIN-LOSS)) 2 AS GB
FROM SCRECORDS
ORDER BY WINS-LOSSES DESC, PCT DESC;
Thanks!