Hi there, hoping someone can help me wrap my head around this query. I need to pull the data from one table and eventually graph the results.
Sample Table Data:
+----------+------------+------------+
| tag | mileage | date |
+----------+------------+------------+
| G1-222 | 45648 | 2010-06-01 |
| G1-222 | 46897 | 2010-07-01 |
| G1-222 | 47851 | 2010-08-01 |
| G2-321 | 12013 | 2010-06-01 |
| G2-321 | 13478 | 2010-07-01 |
| G2-321 | 14897 | 2010-08-01 |
| G2-321 | 15473 | 2010-09-01 |
| G2-4532 | 100 | 2010-06-01 |
| G2-4532 | 250 | 2010-07-01 |
+----------+------------+------------+
I would output for one tag number, a graph for the mileage that car uses each month. I'd like to graph it by month for the previous 12 months, and each line in the graph would be the miles driven for that month, so the calculation would take one month's mileage (odometer reading) - the previous months mileage and output the miles. I'm just not sure how to write the query to do all those calculations and then output.
Thanks for any help.
Sample Table Data:
+----------+------------+------------+
| tag | mileage | date |
+----------+------------+------------+
| G1-222 | 45648 | 2010-06-01 |
| G1-222 | 46897 | 2010-07-01 |
| G1-222 | 47851 | 2010-08-01 |
| G2-321 | 12013 | 2010-06-01 |
| G2-321 | 13478 | 2010-07-01 |
| G2-321 | 14897 | 2010-08-01 |
| G2-321 | 15473 | 2010-09-01 |
| G2-4532 | 100 | 2010-06-01 |
| G2-4532 | 250 | 2010-07-01 |
+----------+------------+------------+
I would output for one tag number, a graph for the mileage that car uses each month. I'd like to graph it by month for the previous 12 months, and each line in the graph would be the miles driven for that month, so the calculation would take one month's mileage (odometer reading) - the previous months mileage and output the miles. I'm just not sure how to write the query to do all those calculations and then output.
Thanks for any help.