Front Office Football Central

Front Office Football Central (https://forums.operationsports.com/fofc//index.php)
-   FOFC Archive (https://forums.operationsports.com/fofc//forumdisplay.php?f=27)
-   -   Help on streamlining a query in MySQL (https://forums.operationsports.com/fofc//showthread.php?t=69474)

Ben E Lou 12-10-2008 05:05 AM

Help on streamlining a query in MySQL
 
I'm trying to look at some era comparisons in FOF. I'm wanting to start with something basic: player ypa for a season versus league-wide ypa for the season. The idea here is that if a guy gets ypa above the league-wide average, he gets a score over 100. It it's below the league-wide average, his score is under 100. Here's the query I created (not certain if this *should* work, even...)

Code:

SELECT sum(s.passyards)/sum(s.passattempts) AS ypa, s.year,  lastname, firstname,
((sum(s.passyards)/sum(s.passattempts))/(SELECT sum(s1.passyards)/sum(s1.passattempts) FROM fof_playergamestats s1 where s1.year=s.year))*100 AS pct,
(SELECT sum(s1.passyards)/sum(s1.passattempts) FROM fof_playergamestats s1 where s1.year=s.year) AS leagueypa
FROM fof_playergamestats s
JOIN fof_playerhistorical h on h.id=s.playerid
GROUP BY s.playerid, s.year
HAVING sum(s.passattempts)>319
ORDER BY pct desc limit 50


It has been running for 10 minutes already, on a relatively fast server. That seems excessive, and I suspect that it's because of something I did wrong there in the nesting. Li'l help?

Drake 12-10-2008 07:40 AM

You need a better join between s and s1 than just Year. Those are pass attempts by player, right? Since you're summing everything, I'd think you'd want year and playerid.


All times are GMT -5. The time now is 11:37 AM.

Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.

Front Office Football Central Database Error
Database Error Database error
The Front Office Football Central database has encountered a problem.

Please try the following:
The forumsold.operationsports.com forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.