IHateMyJob2004
Lifer
I'm the newbie that asked about dev yesterday. As a recap, I am working on a web page using MYSQL server and PHP.
I'm making progress but have a complex query that I need to do and have no idea where to start.
<B>THE DATA</B>
Imagine the following table:
String,int,float are the data types in that order
AA 2000 19.1
AA 2001 15.1
AA 2002 19.0
AA 2003 19.4
AA 2004 19.2
AA 2005 12.1
AA 2006 19.2
AA 2007 12.1
AA 2008 19.2
AA 2009 12.1
BB 2000 19.1
BB 2001 15.1
BB 2002 19.0
BB 2003 19.4
BB 2004 19.2
BB 2005 12.1
BB 2006 19.2
BB 2007 12.1
BB 2008 19.2
Each row has more than 3 pieces of data. More like 50.
And this is stock data. So, ticker, year, value. Thousands of stocks so we're talking a ROM (rough order of magnitude) of 50,000 rows of data.
<B>THE QUERY</B>
Now for the fun. Note that the last year of data that is available is not always the same. BB ends in 2008 while AA ends in 2009. (It gets more fun, CC might only have data for 2008 and 2009 if it's a new stock. Let's ignore that for now unless it is easy to deal with.)
So, I need to get the total for the last 3 years values. How do I do that? For a return value, I really only need the ticker and the 3 year total.
Ya, I'm new to this. Any help is appreciated more than you can imagine.
I'm making progress but have a complex query that I need to do and have no idea where to start.
<B>THE DATA</B>
Imagine the following table:
String,int,float are the data types in that order
AA 2000 19.1
AA 2001 15.1
AA 2002 19.0
AA 2003 19.4
AA 2004 19.2
AA 2005 12.1
AA 2006 19.2
AA 2007 12.1
AA 2008 19.2
AA 2009 12.1
BB 2000 19.1
BB 2001 15.1
BB 2002 19.0
BB 2003 19.4
BB 2004 19.2
BB 2005 12.1
BB 2006 19.2
BB 2007 12.1
BB 2008 19.2
Each row has more than 3 pieces of data. More like 50.
And this is stock data. So, ticker, year, value. Thousands of stocks so we're talking a ROM (rough order of magnitude) of 50,000 rows of data.
<B>THE QUERY</B>
Now for the fun. Note that the last year of data that is available is not always the same. BB ends in 2008 while AA ends in 2009. (It gets more fun, CC might only have data for 2008 and 2009 if it's a new stock. Let's ignore that for now unless it is easy to deal with.)
So, I need to get the total for the last 3 years values. How do I do that? For a return value, I really only need the ticker and the 3 year total.
Ya, I'm new to this. Any help is appreciated more than you can imagine.