Loading ...
Sorry, an error occurred while loading the content.

2165MySQL SQL syntax help

Expand Messages
  • Derek Adair
    Jun 14, 2004
      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?

    • Show all 6 messages in this topic