Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB and SQL Help

Status
Not open for further replies.

rtvillan

Technical User
Joined
Jan 3, 2002
Messages
9
Location
US
Need help in calculating! First of all, I have a database called db1.mdf that has " table1" and has a column for "fuelqty" , "cost"and "Mileage" (number of of mileage). I need to implement the specified data analysis capabilities (cost per mile, and miles per gallon) using SQL queries to retrieve the data from the database. I was told that I should use the following:

(last_fuel_odometer – starting_odometer) / (total_fuel_used) for calculating average miles per gallon and

Total_operating_cost / (current_odometer – starting_odometer) for cost per mile.

Now, not knowing much about SQL (actually 0), what is the best way to approch this. If anyone has a sample code I would greatly appreciate this. I have finals next week and I'm sure this will come up.

Thanks!!!

 
You're on the right track - Try this:
Code:
SELECT [last_fuel_odometer] – [starting_odometer] / [total_fuel_used] AS MilesPerGal, [Total_operating_cost] / [current_odometer] – [starting_odometer] AS CostPerMile
FROM table1;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top