Front Office Football Central  

Go Back   Front Office Football Central > Archives > FOFC Archive
Register FAQ Members List Calendar Mark Forums Read Statistics

Reply
 
Thread Tools
Old 12-10-2008, 04:05 AM   #1
Ben E Lou
Morgado's Favorite Forum Fascist
 
Join Date: Oct 2000
Location: Greensboro, NC
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?
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'!

Ben E Lou is offline   Reply With Quote
Old 12-10-2008, 06:40 AM   #2
Drake
assmaster
 
Join Date: Feb 2001
Location: Bloomington, IN
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.
Drake is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -5. The time now is 12:13 PM.



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