Hi everyone,
Here is my delima... I have a table called mileage which is populated every month with the vehicle stop mileage. So there are multiple entries in the table pertaining to each vehicle. What I am trying to do is write a query that will pull the last entry per vehicle (VID) and give me the total mileage of my fleet.
This is what I currently have, but the result is incorrect. It's display a fleet total of 12,315 total miles when it should actually be around 3,287,169.3.
$total_result=mysql_query("SELECT SUM(mileage.stop) as fleetmiles FROM mileage GROUP BY vid");
while($row=mysql_fetch_array($total_result)) {
$stop = $row['stop'];
$fleetmiles = $row['fleetmiles'];
}
$fleetmiles=number_format($fleetmiles,1,'.',',');
What am I missing??? Please help.
Thank for your time.