Hi guys
You've really helped me out in the past but now I really need your help!
Basically I have a table (name=vehicletable) with the following fields/field data:
Make Model Age Price
Porsche 911 2005 40000
Porsche 911 2006 45000
Porsche 911 2004 35000
Porsche 11 2001 25000
Porsche 911 1999 20000
Porsche 911 2006 45000
Porsche 911 2006 44500
Porsche 911 2004 35250
Porsche 911 2005 40500
The table has thousands of records with varying car manufacturers, models, years and prices (not just Porsches).
I am trying to create a simple line graph to show the depreciation of a specific car (eg Porsche's) using the price by year values in my table (Price Vs Year). The line graph will therefore look something like this:
50000 |
45000 |
40000 |
35000 |
30000 |
25000 |
20000 |
15000 |
10000 |
¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
2002 2003 2004 2005 2006 2007
The script that I am using to render my line graph can be seen below:
------------------SCRIPT----------------------
<script type="text/javascript">
var g = new line_graph();
g.add('1', 145);
g.add('2', 0);
g.add('3', 175);
g.add('4', 130);
g.add('5', 150);
g.add('6', 175);
g.add('7', 205);
g.add('8', 125);
g.add('9', 125);
g.add('10', 135);
g.add('11', 125);
g.render("lineCanvas", "Line Graph");
</script>
---------------------------SCRIPT END--------------------------
The "1,2,3,4,5,6, etc" represents the horizontal axis and the other values represent the vertical axis. Therefore, we would need to populate the horizontal axis with "2002,2003,2004 - 2007" and use the values from the "price" field in the table to populate the vertical axis. I expect I'd need to use an "average" function but I could be wrong. I really have no idea how to approach this.
How on earth do create a sql query to achieve this?
Any ideas would be fully appreciated
I look forward to hearing from you
Best regards
Rod from the UK