Query to total all fuel expenses per month by vehicle

Rik_StHelens

Registered User.
Local time
Today, 14:36
Joined
Sep 15, 2009
Messages
164
Hi

I have a query which should total all fuel expenses, by month for the last 12 months. however, when i run the query, it only displays the first cost incurred by a vehicle in each month column, and not a total of all fuel costs. here is the SQL:

TRANSFORM First(IIf([ReceiptDate]>Date()-365,[Cost],"")) AS FuelCost
SELECT tblFuelReceipts.lkupVehicle, Sum([FuelCost]) AS Total, [Total]/12 AS [Ave per Month]
FROM tblFuelReceipts
GROUP BY tblFuelReceipts.lkupVehicle
PIVOT Format([ReceiptDate],"mmm") In ("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

i based it on another query for our customers vehicles, which does work properly.

Any ideas?

Many Thanks
 

Users who are viewing this thread

Back
Top Bottom