Database schema:
CREATE TABLE Customers (
  id NUMBER PRIMARY KEY,
  name TEXT,
  age NUMBER,
  membership_credit NUMBER
);
CREATE TABLE Discount (
  id NUMBER PRIMARY KEY,
  name TEXT,
  membership_credit NUMBER
);
CREATE TABLE Vehicles (
  id NUMBER PRIMARY KEY,
  name TEXT,
  Model_year NUMBER,
  Type_of_powertrain TEXT,
  Combined_fuel_economy_rate NUMBER,
  City_fuel_economy_rate NUMBER,
  Highway_fuel_economy_rate NUMBER,
  Cost_per_25_miles NUMBER,
  Annual_fuel_cost NUMBER,
  Notes TEXT
);
CREATE TABLE Renting_history (
  id NUMBER PRIMARY KEY,
  customer_id NUMBER,
  discount_id NUMBER,
  vehicles_id NUMBER,
  total_hours NUMBER,
  FOREIGN KEY (discount_id) REFERENCES Discount(id),
  FOREIGN KEY (vehicles_id) REFERENCES Vehicles(id),
  FOREIGN KEY (customer_id) REFERENCES Customers(id)
);

Question: Show name and model year for vehicles with city fuel economy rate less than or equal to highway fuel economy rate.
SQL: SELECT name ,  model_year FROM vehicles WHERE city_fuel_economy_rate  <=  highway_fuel_economy_rate

Question: What are the names of all vehicles, ordered by model year descending?
SQL: SELECT name FROM vehicles ORDER BY model_year DESC

Question: How many vehicles do we have?
SQL: SELECT count(*) FROM vehicles

Question: Show name, type of powertrain, and annual fuel cost for all vehicles with model year 2013 or 2014.
SQL: SELECT name ,  type_of_powertrain ,  annual_fuel_cost FROM vehicles WHERE model_year  =  2013 OR model_year  =  2014

Question: What is the discount name with most number of renting history records?
SQL: SELECT T2.name FROM renting_history AS T1 JOIN discount AS T2 ON T1.discount_id  =  T2.id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1

Question: What are the names and powertrain types of cars that have more than 30 total rental hours?
SQL: SELECT T2.name ,  T2.Type_of_powertrain FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T1.vehicles_id HAVING sum(T1.total_hours)  >  30

Question: What is the type of powertrain with most number of vehicles.
SQL: SELECT type_of_powertrain FROM vehicles GROUP BY type_of_powertrain ORDER BY count(*) DESC LIMIT 1

Question: What are the names and total rental hours for each vehicle?
SQL: SELECT T2.name ,  sum(T1.total_hours) FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T2.id

Question: Show the type of powertrain with at least two vehicles, and the average annual fuel cost for vehicles in each such type.
SQL: SELECT type_of_powertrain ,  avg(annual_fuel_cost) FROM vehicles GROUP BY type_of_powertrain HAVING count(*)  >=  2

Question: Show the name of customer with at least two renting history records.
SQL: SELECT T2.name FROM renting_history AS T1 JOIN customers AS T2 ON T1.customer_id  =  T2.id GROUP BY T2.id HAVING count(*)  >=  2

Question: Show the vehicle name with a descending order of total hours of renting.
SQL: SELECT T2.name FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T2.id ORDER BY sum(T1.total_hours) DESC

Question: Find the name and powertrain type of the cars that rented for more than 30 total hours.
SQL: SELECT T2.name ,  T2.Type_of_powertrain FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T1.vehicles_id HAVING sum(T1.total_hours)  >  30

Question: What are the names of vehicles that have never been rented?
SQL: SELECT name FROM vehicles WHERE id NOT IN (SELECT vehicles_id FROM renting_history)

Question: Find the average city and highway fuel rates for cars with different powertrain types.
SQL: SELECT avg(City_fuel_economy_rate) ,  avg(Highway_fuel_economy_rate) , Type_of_powertrain FROM vehicles GROUP BY Type_of_powertrain

Question: Show the name and total hours of renting for each vehicle.
SQL: SELECT T2.name ,  sum(T1.total_hours) FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T2.id

Question: Show types of powertrain with vehicles both from 2014 and 2013.
SQL: SELECT type_of_powertrain FROM vehicles WHERE model_year  =  2014 INTERSECT SELECT type_of_powertrain FROM vehicles WHERE model_year  =  2013

Question: Return the name of the discount that corresponds to the most rental history records.
SQL: SELECT T2.name FROM renting_history AS T1 JOIN discount AS T2 ON T1.discount_id  =  T2.id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1

Question: What are the names, types of powertrains, and yearly fuel costs for vehicles with model years in either 2013 2014?
SQL: SELECT name ,  type_of_powertrain ,  annual_fuel_cost FROM vehicles WHERE model_year  =  2013 OR model_year  =  2014

Question: How many vehicles have each type of powertrain?
SQL: SELECT type_of_powertrain ,  count(*) FROM vehicles GROUP BY type_of_powertrain

Question: What are the minimum, maximum, and average annual fuel costs across all vehicles?
SQL: SELECT min(annual_fuel_cost) ,  max(annual_fuel_cost) ,  avg(annual_fuel_cost) FROM vehicles

Question: Return the average age for customers who have membership above the average across all customers.
SQL: SELECT avg(age) FROM customers WHERE membership_credit  >  (SELECT avg(membership_credit) FROM customers)

Question: What is the name and model year of the vehicle which has been rented the most times?
SQL: SELECT T2.name ,  T2.model_year FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1

Question: What are the types of powertrains for which there are two or more vehicles, and what are their average annual fuel costs?
SQL: SELECT type_of_powertrain ,  avg(annual_fuel_cost) FROM vehicles GROUP BY type_of_powertrain HAVING count(*)  >=  2

Question: Which type of powertrain is most common?
SQL: SELECT type_of_powertrain FROM vehicles GROUP BY type_of_powertrain ORDER BY count(*) DESC LIMIT 1

Question: What are the names of vehicles, sorted descending by total hours of renting?
SQL: SELECT T2.name FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T2.id ORDER BY sum(T1.total_hours) DESC

Question: Show the name and age of the customer with maximum membership credit.
SQL: SELECT name ,  age FROM customers ORDER BY membership_credit DESC LIMIT 1

Question: Show minimum, maximum, and average annual fuel cost for all vehicles.
SQL: SELECT min(annual_fuel_cost) ,  max(annual_fuel_cost) ,  avg(annual_fuel_cost) FROM vehicles

Question: What is the name and age of the customer with the most membership credit?
SQL: SELECT name ,  age FROM customers ORDER BY membership_credit DESC LIMIT 1

Question: Show the name and model year of the vehicle with most number of renting history records.
SQL: SELECT T2.name ,  T2.model_year FROM renting_history AS T1 JOIN vehicles AS T2 ON T1.vehicles_id  =  T2.id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1

Question: What are the names of customers who have two or more records of rental history?
SQL: SELECT T2.name FROM renting_history AS T1 JOIN customers AS T2 ON T1.customer_id  =  T2.id GROUP BY T2.id HAVING count(*)  >=  2

Question: Return all information about discounts.
SQL: SELECT * FROM discount

Question: Show all types of powertrain and the number of vehicles in each type.
SQL: SELECT type_of_powertrain ,  count(*) FROM vehicles GROUP BY type_of_powertrain

Question: What are the average city fuel economy rate, average highway fuel economy rate for different types of powertrains?
SQL: SELECT avg(City_fuel_economy_rate) ,  avg(Highway_fuel_economy_rate) , Type_of_powertrain FROM vehicles GROUP BY Type_of_powertrain

Question: What are the types of powertrains that have vehicles that were made in both 2013 and 2014?
SQL: SELECT type_of_powertrain FROM vehicles WHERE model_year  =  2014 INTERSECT SELECT type_of_powertrain FROM vehicles WHERE model_year  =  2013