attention Ken calculated values

S

Stephen

Thanks Ken for your help on calculated values

a forgotten problem has popped up

this is the working SQL query but I forgot I changed vehicles March 16
so I need to look at changing total mileage as mileage from Jan 1 to
March 16 plus mileage till end of year

do add a between date statement to the end of min and max lines of code

SELECT MIN([start mileage]) AS [Start of year mileage],
MAX([home mileage]) AS [End of year mileage],
MAX([home mileage])-MIN([start mileage]) AS [Total mileage],
SUM([home mileage]-[start mileage]) AS [Total business mileage],
SUM([gas]) AS [Sum Of gas], SUM([US gas]) AS [Sum Of US gas],
SUM([US gas2]) AS [Sum Of US gas2],
SUM([servise $]) AS [Sum Of servise $],
SUM([us cost]) AS [Sum Of us cost],
SUM([gas pur]) AS [Sum Of gas pur],
SUM([insureance]) AS [Sum Of insureance],
SUM([plate]) AS [Sum Of plate]
FROM [travel 2007];

I did try this but it gives me an error 'operator not found' I believe

SELECT
MIN([start mileage]) AS [Start of year mileage] FROM [travel
2007]WHERE ([Date]) BETWEEN #01/01/2005# and #16/03/2005#;
MAX([home mileage]) AS [End of year mileage] FROM [travel 2007]WHERE
([Date]) BETWEEN #01/01/2005# and #16/03/2005#;
MIN([start mileage]) AS [Start of year mileage2] FROM [travel
2007]WHERE ([Date]) BETWEEN #16/03/2005# and #31/12/2005#;
MAX([home mileage]) AS [End of year mileage2] FROM [travel 2007]WHERE
([Date]) BETWEEN #16/03/2005# and #31/12/2005#;
SUM([home mileage]-[start mileage]) AS [Total business mileage],
SUM([gas]) AS [Sum Of gas],
SUM([US gas]) AS [Sum Of US gas],
SUM([US gas2]) AS [Sum Of US gas2],
SUM([servise $]) AS [Sum Of servise $],
SUM([us cost]) AS [Sum Of us cost],
SUM([gas pur]) AS [Sum Of gas pur],
SUM([insureance]) AS [Sum Of insureance],
SUM([plate]) AS [Sum Of plate]
FROM [travel 2007];


thanks for your advise
Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top