Hey guys,
Still trying to put a web site together based off the SQLite DB. I'm making progress but I'm having an issue calculating GAA. I know what the calculation should be (GoalerProStat.GA / (GoalerProStat.SecondPlay / 60))*60 but I can't seem to put that into PHP code. Anyone have any ideas?
Thanks in advance,
Brandyn
Calculating GAA from SQLite DB
-
- New in Town / Le Ptit Nouveau
- Posts: 43
- Joined: Tue Jun 19, 2012 1:25 pm
-
- New in Town / Le Ptit Nouveau
- Posts: 43
- Joined: Tue Jun 19, 2012 1:25 pm
Re: Calculating GAA from SQLite DB
Of course I've been looking at this for a few days and once I post this I figure it out. Here's what worked for me:
SELECT GoalerInfo.Name, GoalerInfo.Number, GoalerInfo.Team, GoalerProStat.SA, GoalerProStat.GA, GoalerProStat.GP, ROUND((CAST(GoalerProStat.GA AS REAL) / (GoalerProStat.SecondPlay / 60))*60,3) AS GAA FROM GoalerInfo INNER JOIN GoalerProStat ON GoalerInfo.Number = GoalerProStat.Number WHERE GoalerInfo.TeamName = '$TeamName' ORDER BY GAA DESC LIMIT 2
then just echo $row['GAA']
I'm not PHP expert and there probably is another way to do this but this worked for me.
SELECT GoalerInfo.Name, GoalerInfo.Number, GoalerInfo.Team, GoalerProStat.SA, GoalerProStat.GA, GoalerProStat.GP, ROUND((CAST(GoalerProStat.GA AS REAL) / (GoalerProStat.SecondPlay / 60))*60,3) AS GAA FROM GoalerInfo INNER JOIN GoalerProStat ON GoalerInfo.Number = GoalerProStat.Number WHERE GoalerInfo.TeamName = '$TeamName' ORDER BY GAA DESC LIMIT 2
then just echo $row['GAA']
I'm not PHP expert and there probably is another way to do this but this worked for me.
Re: Calculating GAA from SQLite DB
You should change this :
ROUND((CAST(GoalerProStat.GA AS REAL) / (GoalerProStat.SecondPlay / 60))*60,3) AS GAA
By
ROUND((GoalerProstat.GA*60)/(GoalerProStat.SecondPlay/60),2) AS GAA
Which is more the real formula. Using CAST should be not necessary. If it does, you should write it that way while it's the result you want as REAL not only the GA :
ROUND(CAST((GoalerProstat.GA*60)/(GoalerProStat.SecondPlay/60) AS REAL),2) AS GAA
ROUND((CAST(GoalerProStat.GA AS REAL) / (GoalerProStat.SecondPlay / 60))*60,3) AS GAA
By
ROUND((GoalerProstat.GA*60)/(GoalerProStat.SecondPlay/60),2) AS GAA
Which is more the real formula. Using CAST should be not necessary. If it does, you should write it that way while it's the result you want as REAL not only the GA :
ROUND(CAST((GoalerProstat.GA*60)/(GoalerProStat.SecondPlay/60) AS REAL),2) AS GAA
-
- New in Town / Le Ptit Nouveau
- Posts: 43
- Joined: Tue Jun 19, 2012 1:25 pm
Re: Calculating GAA from SQLite DB
If I make your changes then I only get whole numbers. For instance I had 1.8, 2.2, 2.7, 2.8 and I now have 1, 2, 2, 3.