2168Re: [baseball-databank] MySQL SQL syntax help
- Jun 14, 2004Why not just create a view containing a players yearly counting stats
and run another query against that. For example:
create or replace view batting_yearly as
group by playerID,
where yearID between &start_year and &end_year
group by yearID;
I use MS Access, Oracle MS and Sybase SQL Server so the syntax may be a
little different for MySQL.
On Mon, 14 Jun 2004 12:50:00 -0700 (PDT), "Tangotiger"
> I'm having a heckuva time following the request here
> (though, the A/C is out here, and I can barely focus).
> If you send me an email with your contact number, I
> can call you, and I'm sure we can figure it out.
> (Unless Michael M has already figured it out.)
> --- Derek Adair <dadair@...> wrote:
> > I'm looking for an MySQL-compatible SQL query that
> > will, given a year
> > range and a stat, provide me with either (ideally) a
> > major league average
> > per year for that stat or a result set I can
> > calculate that average from
> > (PlayerID, Year, Stat). I'm running into a few
> > problems. The average needs
> > to be calculated after a grouping by PlayerID, then
> > Year, since I don't
> > want a player with two or more stints getting a
> > lower total averaged in.
> > I'm not sure how to group by two variables, and I
> > don't know how two
> > layers of aggregation can be accomplished (SUM, then
> > AVG). Subqueries
> > would seem to help a bit, but I can't see how to get
> > all the way there,
> > even if I upgrade to 4.1 alpha.
> > Any thoughts?
> > Regards,
> > Derek
> Do you Yahoo!?
> Friends. Fun. Try the all-new Yahoo! Messenger.
> Yahoo! Groups Sponsor
> click here
> Yahoo! Groups Links
> * To visit your group on the web, go to:
> * To unsubscribe from this group, send an email to:
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms
> of Service.
> 1. http://messenger.yahoo.com/
> 2. http://www.baseball-databank.org/
> 4. http://groups.yahoo.com/group/baseball-databank/
> 6. http://docs.yahoo.com/info/terms/
- << Previous post in topic Next post in topic >>