MySQL query question... Ok, here's the deal. I'm working on a home project, and I'm having a bit of a problem.I have a query that gets points for, points against, and points differential.This part of the query works fine, because these are calculated by my C#, and stored in the DB.The problem is, I'm trying to get a percentage for the points differential, using something akin to this:
SELECT T.TEAM_NAME, S.POINTS_FOR, S.POINTS_ALLOWED, S.POINTS_DIFFERENTIAL,(S.POINTS_DIFFERENTIAL / MAX(S.POINTS_DIFFERENTIAL)) AS PDFROM SCORES SINNER JOIN TEAMS TON S.TEAM_ID = T.IDGROUP BY T.TEAM_NAME;
The results look something like this:
| Team Name | Points Scored | Points Allowed | Points Difference | PD | | Team A | 10 | 14 | -4 | 1.0000 | | Team B | 28 | 10 | 18 | 1.0000 | | Team C | 35 | 27 | 8 | 1.0000 | | Team D | 12 | 10 | 2 | 1.0000 | | Team E | 14 | 0 | 14 | 1.0000 |
The problem with this is the math in the last column is way wrong. It should not be 1.0000 in each column. The last column should have the following values:
-.2222, 1.0000, .4444, .1111, .7777
I know I'm missing something simple. But what? I'll probably kick myself when I find out what it is...INVALID ARGUMENT*** |