Calculating GAA from SQLite DB

If you need help building your website, this is the place to hang out. If you're an HTML, PHP, Perl or web database geek, check it out. / Si vous avez besoin d'aide pour construire votre site web, c'est le forum à regarder! Si vous êtes un expert en HTML, PHP, Perl ou en base de données, c'est le forum pour vous!
Post Reply
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Calculating GAA from SQLite DB

Post 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
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Calculating GAA from SQLite DB

Post 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.
JimToupet
STHS Dynamic Website Contributor
Posts: 363
Joined: Wed Jul 02, 2014 10:55 am

Re: Calculating GAA from SQLite DB

Post 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
Bmoney0313
New in Town / Le Ptit Nouveau
Posts: 43
Joined: Tue Jun 19, 2012 1:25 pm

Re: Calculating GAA from SQLite DB

Post 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.
Post Reply