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

3758Re: HACKS - Positions

Expand Messages
  • William
    May 8, 2009
    • 0 Attachment
      I just figured it out:

      SELECT
      f2.yearid,
      f2.playerid,
      MID(MAX(CONCAT(1000 + CAST(f2.GP as CHAR(3)),"_",f2.pos)),6) AS PrimPos,
      Max(f2.GP) AS GP_Pos, SUM(f2.GP) AS GP_sum,
      IF(SUM(1) = 1,"",MID(MIN(CONCAT(1000 + CAST(f2.GP as CHAR(3)),"_",f2.pos)),6)) AS LastPos
      FROM
      (SELECT
      yearid,
      playerid,
      pos,
      SUM(g) as GP
      from fielding
      group by yearid, playerid, pos) AS f2
      GROUP BY f2.yearid, f2.playerid

      --- In baseball-databank@yahoogroups.com, "Tangotiger" <tom@...> wrote:
      >
      > Can you show us what functions you've tried?
      >
      > Here's a related one in Oracle I've used (for something else):
      > substr(min(to_char(order_id + 90000,'00000') ||
      > to_char(mlbam_id,'000000')),8,6) as best_mlbam_id
      >
      > See if the idea there helps any.
      >
      > Tom
      >
      >
      >
      > > Is there a MySQL equivalent to this query? I'm struggling with converting
      > > it from Access to Mysql.
      > >
      > > --- In baseball-databank@yahoogroups.com, Tangotiger <tangotiger@>
      > > wrote:
      > >>
      > >> There's a few posts here that might be of interest to
      > >> those working with primary positions:
      > >>
      > >> http://www.insidethebook.com/ee/index.php/site/comments/database_hacks/
      > >>
      > >> Tom
      > >>
      > >>
      > >> ---------------------------------------------
      > >> http://www.InsideTheBook.com
      > >> The Book--Playing The Percentages In Baseball
      > >>
      > >>
      > >>
      > >>
      > >>
      > >>
      > >>
      > >>
      > >>
      > >>
      > >>
      > >> -----------------------------------
      > >>
      > >>
      > >>
      > >> ____________________________________________________________________________________
      > >> Now that's room service! Choose from over 150,000 hotels
      > >> in 45,000 destinations on Yahoo! Travel to find your fit.
      > >> http://farechase.yahoo.com/promo-generic-14795097
      > >>
      > >
      > >
      > >
      >
      >
      > ---------------------------------------------
      > The Book--Playing The Percentages In Baseball
      > http://www.InsideTheBook.com
      >
    • Show all 20 messages in this topic