Page 1 of 1

Calculating GAA from SQLite DB

Posted: Thu Oct 01, 2015 8:43 am
by Bmoney0313
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

Re: Calculating GAA from SQLite DB

Posted: Thu Oct 01, 2015 8:53 am
by Bmoney0313
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.

Re: Calculating GAA from SQLite DB

Posted: Thu Oct 08, 2015 11:19 pm
by JimToupet
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

Re: Calculating GAA from SQLite DB

Posted: Fri Oct 09, 2015 7:27 am
by Bmoney0313
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.