MySQL Forums :: Newbie :: Adding Segments in Table


Advanced Search

Adding Segments in Table
Posted by: Eric Seidman ()
Date: May 07, 2009 10:47AM

Okay, I have a table that houses stats for every single game for a pitcher in each of his seasons.

I then created a table from that with data just from 2002. One of the columns in the table numbers the games in order of date. That column is called GP_NUM.

What I want to do is calculate the SUM of a stat for every 10-game interval for each pitcher, so each pitcher will have the SUM for Games 1-10, 2-11, 3-12, etc.

I tried running this query but it only showed me the BB total for each of the games involved, not the sum between the games. How can I fix the below query to do what I want?

SELECT pitcher, pitcher_team, year_id, GP_NUM, GP_NUM+9, SUM(BB)
FROM LOGS02
WHERE GP_NUM BETWEEN GP_NUM AND GP_NUM+9
GROUP BY RES_PIT_ID, GP_NUM

Options: ReplyQuote


Subject Written By Posted
Adding Segments in Table Eric Seidman 05/07/2009 10:47AM
Re: Adding Segments in Table Mark Snyder 05/07/2009 10:55AM
Re: Adding Segments in Table Eric Seidman 05/07/2009 12:15PM
Re: Adding Segments in Table Rick James 05/07/2009 10:41PM
Re: Adding Segments in Table Guelphdad Lake 05/08/2009 07:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.