Database: car_1
# continents ( contid , continent )
# countries ( countryid , countryname , continent )
# car_makers ( id , maker , fullname , country )
# model_list ( modelid , maker , model )
# car_names ( makeid , model , make )
# cars_data ( id , mpg , cylinders , edispl , horsepower , weight , accelerate , year )
# countries.continent = continents.contid
# car_makers.country = countries.countryid
# model_list.maker = car_makers.id
# car_names.model = model_list.model
# cars_data.id = car_names.makeid

Question: How many continents are there?
SQL: select count ( * ) from continents

Question: What is the number of continents?
SQL: select count ( * ) from continents

Question: How many countries does each continent have? List the continent id, continent name and the number of countries.
SQL: select continents.contid , continents.continent , count ( * ) from continents join countries on continents.contid = countries.continent group by continents.contid

Question: For each continent, list its id, name, and how many countries it has?
SQL: select continents.contid , continents.continent , count ( * ) from continents join countries on continents.contid = countries.continent group by continents.contid

Question: How many countries are listed?
SQL: select count ( * ) from countries

Question: How many countries exist?
SQL: select count ( * ) from countries

Question: How many models does each car maker produce? List maker full name, id and the number.
SQL: select car_makers.fullname , car_makers.id , count ( * ) from car_makers join model_list on car_makers.id = model_list.maker group by car_makers.id

Question: What is the full name of each car maker, along with its id and how many models it produces?
SQL: select car_makers.fullname , car_makers.id , count ( * ) from car_makers join model_list on car_makers.id = model_list.maker group by car_makers.id

Question: Which model of the car has the minimum horsepower?
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id order by cars_data.horsepower asc limit 1

Question: What is the model of the car with the smallest amount of horsepower?
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id order by cars_data.horsepower asc limit 1

Question: Find the model of the car whose weight is below the average weight.
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id where cars_data.weight < ( select avg ( weight ) from cars_data )

Question: What is the model for the car with a weight smaller than the average?
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id where cars_data.weight < ( select avg ( weight ) from cars_data )

Question: Find the name of the makers that produced some cars in the year of 1970?
SQL: select distinct car_makers.maker from car_makers join model_list on car_makers.id = model_list.maker join car_names on model_list.model = car_names.model join cars_data on car_names.makeid = cars_data.id where cars_data.year = '1970'

Question: What is the name of the different car makers who produced a car in 1970?
SQL: select distinct car_makers.maker from car_makers join model_list on car_makers.id = model_list.maker join car_names on model_list.model = car_names.model join cars_data on car_names.makeid = cars_data.id where cars_data.year = '1970'

Question: Find the make and production time of the cars that were produced in the earliest year?
SQL: select car_names.make , cars_data.year from cars_data join car_names on cars_data.id = car_names.makeid where cars_data.year = ( select min ( year ) from cars_data )

Question: What is the maker of the carr produced in the earliest year and what year was it?
SQL: select car_names.make , cars_data.year from cars_data join car_names on cars_data.id = car_names.makeid where cars_data.year = ( select min ( year ) from cars_data )

Question: Which distinct car models are the produced after 1980?
SQL: select distinct model_list.model from model_list join car_names on model_list.model = car_names.model join cars_data on car_names.makeid = cars_data.id where cars_data.year > 1980

Question: What are the different models for the cards produced after 1980?
SQL: select distinct model_list.model from model_list join car_names on model_list.model = car_names.model join cars_data on car_names.makeid = cars_data.id where cars_data.year > 1980

Question: How many car makers are there in each continents? List the continent name and the count.
SQL: select continents.continent , count ( * ) from continents join countries on continents.contid = countries.continent join car_makers on countries.countryid = car_makers.country group by continents.continent

Question: What is the name of each continent and how many car makers are there in each one?
SQL: select continents.continent , count ( * ) from continents join countries on continents.contid = countries.continent join car_makers on countries.countryid = car_makers.country group by continents.continent

Question: Which of the countries has the most car makers? List the country name.
SQL: select countries.countryname from car_makers join countries on car_makers.country = countries.countryid group by car_makers.country order by count ( * ) desc limit 1

Question: What is the name of the country with the most car makers?
SQL: select countries.countryname from car_makers join countries on car_makers.country = countries.countryid group by car_makers.country order by count ( * ) desc limit 1

Question: How many car models are produced by each maker ? Only list the count and the maker full name .
SQL: select count ( * ) , car_makers.fullname from model_list join car_makers on model_list.maker = car_makers.id group by car_makers.id

Question: What is the number of car models that are produced by each maker and what is the id and full name of each maker?
SQL: select count ( * ) , car_makers.fullname , car_makers.id from model_list join car_makers on model_list.maker = car_makers.id group by car_makers.id

Question: What is the accelerate of the car make amc hornet sportabout (sw)?
SQL: select cars_data.accelerate from cars_data join car_names on cars_data.id = car_names.makeid where car_names.make = 'amc hornet sportabout (sw)'

Question: How much does the car accelerate that makes amc hornet sportabout (sw)?
SQL: select cars_data.accelerate from cars_data join car_names on cars_data.id = car_names.makeid where car_names.make = 'amc hornet sportabout (sw)'

Question: How many car makers are there in france?
SQL: select count ( * ) from car_makers join countries on car_makers.country = countries.countryid where countries.countryname = 'france'

Question: What is the number of makers of care in France?
SQL: select count ( * ) from car_makers join countries on car_makers.country = countries.countryid where countries.countryname = 'france'

Question: How many car models are produced in the usa?
SQL: select count ( * ) from model_list join car_makers on model_list.maker = car_makers.id join countries on car_makers.country = countries.countryid where countries.countryname = 'usa'

Question: What is the count of the car models produced in the United States?
SQL: select count ( * ) from model_list join car_makers on model_list.maker = car_makers.id join countries on car_makers.country = countries.countryid where countries.countryname = 'usa'

Question: What is the average miles per gallon(mpg) of the cars with 4 cylinders?
SQL: select avg ( mpg ) from cars_data where cylinders = 4

Question: What is the average miles per gallon of all the cards with 4 cylinders?
SQL: select avg ( mpg ) from cars_data where cylinders = 4

Question: What is the smallest weight of the car produced with 8 cylinders on 1974 ?
SQL: select min ( weight ) from cars_data where cylinders = 8 and year = 1974

Question: What is the minimum weight of the car with 8 cylinders produced in 1974 ?
SQL: select min ( weight ) from cars_data where cylinders = 8 and year = 1974

Question: What are all the makers and models?
SQL: select maker , model from model_list

Question: What are the makers and models?
SQL: select maker , model from model_list

Question: What are the countries having at least one car maker? List name and id.
SQL: select countries.countryname , countries.countryid from countries join car_makers on countries.countryid = car_makers.country group by countries.countryid having count ( * ) >= 1

Question: What are the names and ids of all countries with at least one car maker?
SQL: select countries.countryname , countries.countryid from countries join car_makers on countries.countryid = car_makers.country group by countries.countryid having count ( * ) >= 1

Question: What is the number of the cars with horsepower more than 150?
SQL: select count ( * ) from cars_data where horsepower > 150

Question: What is the number of cars with a horsepower greater than 150?
SQL: select count ( * ) from cars_data where horsepower > 150

Question: What is the average weight of cars each year?
SQL: select avg ( weight ) , year from cars_data group by year

Question: What is the average weight and year for each year?
SQL: select avg ( weight ) , year from cars_data group by year

Question: Which countries in europe have at least 3 car manufacturers?
SQL: select countries.countryname from countries join continents on countries.continent = continents.contid join car_makers on countries.countryid = car_makers.country where continents.continent = 'europe' group by countries.countryname having count ( * ) >= 3

Question: What are the names of all European countries with at least 3 manufacturers?
SQL: select countries.countryname from countries join continents on countries.continent = continents.contid join car_makers on countries.countryid = car_makers.country where continents.continent = 'europe' group by countries.countryname having count ( * ) >= 3

Question: What is the maximum horsepower and the make of the car models with 3 cylinders?
SQL: select cars_data.horsepower , car_names.make from car_names join cars_data on car_names.makeid = cars_data.id where cars_data.cylinders = 3 order by cars_data.horsepower desc limit 1

Question: What is the largest amount of horsepower for the models with 3 cylinders and what make is it?
SQL: select cars_data.horsepower , car_names.make from car_names join cars_data on car_names.makeid = cars_data.id where cars_data.cylinders = 3 order by cars_data.horsepower desc limit 1

Question: Which model saves the most gasoline? That is to say, have the maximum miles per gallon.
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id order by cars_data.mpg desc limit 1

Question: What is the car model with the highest mpg ?
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id order by cars_data.mpg desc limit 1

Question: What is the average horsepower of the cars before 1980?
SQL: select avg ( horsepower ) from cars_data where year < 1980

Question: What is the average horsepower for all cars produced before 1980 ?
SQL: select avg ( horsepower ) from cars_data where year < 1980

Question: What is the average edispl of the cars of model volvo?
SQL: select avg ( cars_data.edispl ) from car_names join cars_data on car_names.makeid = cars_data.id where car_names.model = 'volvo'

Question: What is the average edispl for all volvos?
SQL: select avg ( cars_data.edispl ) from car_names join cars_data on car_names.makeid = cars_data.id where car_names.model = 'volvo'

Question: What is the maximum accelerate for different number of cylinders?
SQL: select max ( accelerate ) , cylinders from cars_data group by cylinders

Question: What is the maximum accelerate for all the different cylinders?
SQL: select max ( accelerate ) , cylinders from cars_data group by cylinders

Question: Which model has the most version(make) of cars?
SQL: select model from car_names group by model order by count ( * ) desc limit 1

Question: What model has the most different versions?
SQL: select model from car_names group by model order by count ( * ) desc limit 1

Question: How many cars have more than 4 cylinders?
SQL: select count ( * ) from cars_data where cylinders > 4

Question: What is the number of cars with more than 4 cylinders?
SQL: select count ( * ) from cars_data where cylinders > 4

Question: how many cars were produced in 1980?
SQL: select count ( * ) from cars_data where year = 1980

Question: In 1980, how many cars were made?
SQL: select count ( * ) from cars_data where year = 1980

Question: How many car models were produced by the maker with full name American Motor Company?
SQL: select count ( * ) from car_makers join model_list on car_makers.id = model_list.maker where car_makers.fullname = 'American Motor Company'

Question: What is the number of car models created by the car maker American Motor Company?
SQL: select count ( * ) from car_makers join model_list on car_makers.id = model_list.maker where car_makers.fullname = 'American Motor Company'

Question: Which makers designed more than 3 car models? List full name and the id.
SQL: select car_makers.fullname , car_makers.id from car_makers join model_list on car_makers.id = model_list.maker group by car_makers.id having count ( * ) > 3

Question: What are the names and ids of all makers with more than 3 models?
SQL: select car_makers.fullname , car_makers.id from car_makers join model_list on car_makers.id = model_list.maker group by car_makers.id having count ( * ) > 3

Question: Which distinctive models are produced by maker with the full name General Motors or weighing more than 3500?
SQL: select distinct model_list.model from car_names join model_list on car_names.model = model_list.model join car_makers on model_list.maker = car_makers.id join cars_data on car_names.makeid = cars_data.id where car_makers.fullname = 'General Motors' or cars_data.weight > 3500

Question: What are the different models created by either the car maker General Motors or weighed more than 3500?
SQL: select distinct model_list.model from car_names join model_list on car_names.model = model_list.model join car_makers on model_list.maker = car_makers.id join cars_data on car_names.makeid = cars_data.id where car_makers.fullname = 'General Motors' or cars_data.weight > 3500

Question: In which years cars were produced weighing no less than 3000 and no more than 4000 ?
SQL: select distinct year from cars_data where weight between 3000 and 4000

Question: What are the different years in which there were cars produced that weighed less than 4000 and also cars that weighted more than 3000 ?
SQL: select distinct year from cars_data where weight between 3000 and 4000

Question: What is the horsepower of the car with the largest accelerate?
SQL: select cars_data.horsepower from cars_data order by cars_data.accelerate desc limit 1

Question: What is the horsepower of the car with the greatest accelerate?
SQL: select cars_data.horsepower from cars_data order by cars_data.accelerate desc limit 1

Question: For model volvo, how many cylinders does the car with the least accelerate have?
SQL: select cars_data.cylinders from cars_data join car_names on cars_data.id = car_names.makeid where car_names.model = 'volvo' order by cars_data.accelerate asc limit 1

Question: For a volvo model, how many cylinders does the version with least accelerate have?
SQL: select cars_data.cylinders from cars_data join car_names on cars_data.id = car_names.makeid where car_names.model = 'volvo' order by cars_data.accelerate asc limit 1

Question: How many cars have a larger accelerate than the car with the largest horsepower?
SQL: select count ( * ) from cars_data where accelerate > ( select accelerate from cars_data order by horsepower desc limit 1 )

Question: What is the number of cars with a greater accelerate than the one with the most horsepower?
SQL: select count ( * ) from cars_data where accelerate > ( select accelerate from cars_data order by horsepower desc limit 1 )

Question: How many countries has more than 2 car makers ?
SQL: select count ( * ) from countries join car_makers on countries.countryid = car_makers.country group by countries.countryid having count ( * ) > 2

Question: What is the number of countries with more than 2 car makers ?
SQL: select count ( * ) from countries join car_makers on countries.countryid = car_makers.country group by countries.countryid having count ( * ) > 2

Question: How many cars has over 6 cylinders?
SQL: select count ( * ) from cars_data where cylinders > 6

Question: What is the number of carsw ith over 6 cylinders?
SQL: select count ( * ) from cars_data where cylinders > 6

Question: For the cars with 4 cylinders, which model has the largest horsepower?
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id where cars_data.cylinders = 4 order by cars_data.horsepower desc limit 1

Question: For all of the 4 cylinder cars, which model has the most horsepower?
SQL: select car_names.model from car_names join cars_data on car_names.makeid = cars_data.id where cars_data.cylinders = 4 order by cars_data.horsepower desc limit 1

Question: Among the cars with more than lowest horsepower, which ones do not have more than 3 cylinders? List the car makeid and make name.
SQL: select car_names.makeid , car_names.make from cars_data join car_names on cars_data.id = car_names.makeid where cars_data.horsepower > ( select min ( horsepower ) from cars_data ) and cars_data.cylinders <= 3

Question: Among the cars that do not have the minimum horsepower , what are the make ids and names of all those with less than 4 cylinders ?
SQL: select car_names.makeid , car_names.make from cars_data join car_names on cars_data.id = car_names.makeid where cars_data.horsepower > ( select min ( horsepower ) from cars_data ) and cars_data.cylinders < 4

Question: What is the maximum miles per gallon of the car with 8 cylinders or produced before 1980 ?
SQL: select max ( mpg ) from cars_data where cylinders = 8 or year < 1980

Question: What is the maximum mpg of the cars that had 8 cylinders or that were produced before 1980 ?
SQL: select max ( mpg ) from cars_data where cylinders = 8 or year < 1980

Question: Which models are lighter than 3500 but not built by the 'Ford Motor Company'?
SQL: select distinct model_list.model from model_list join car_names on model_list.model = car_names.model join cars_data on car_names.makeid = cars_data.id join car_makers on model_list.maker = car_makers.id where cars_data.weight < 3500 and car_makers.fullname != 'Ford Motor Company'

Question: What are the different models wthat are lighter than 3500 but were not built by the Ford Motor Company?
SQL: select distinct model_list.model from model_list join car_names on model_list.model = car_names.model join cars_data on car_names.makeid = cars_data.id join car_makers on model_list.maker = car_makers.id where cars_data.weight < 3500 and car_makers.fullname != 'Ford Motor Company'

Question: What are the name of the countries where there is not a single car maker?
SQL: select countryname from countries except select countries.countryname from countries join car_makers on countries.countryid = car_makers.country

Question: What are the names of the countries with no car makers?
SQL: select countryname from countries except select countries.countryname from countries join car_makers on countries.countryid = car_makers.country

Question: Which are the car makers which produce at least 2 models and more than 3 car makers ? List the id and the maker .
SQL: select car_makers.id , car_makers.maker from car_makers join model_list on car_makers.id = model_list.maker group by car_makers.id having count ( * ) >= 2 intersect select car_makers.id , car_makers.maker from car_makers join model_list on car_makers.id = model_list.maker join car_names on model_list.model = car_names.model group by car_makers.id having count ( * ) > 3

Question: What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?
SQL: select car_makers.id , car_makers.maker from car_makers join model_list on car_makers.id = model_list.maker group by car_makers.id having count ( * ) >= 2 intersect select car_makers.id , car_makers.maker from car_makers join model_list on car_makers.id = model_list.maker join car_names on model_list.model = car_names.model group by car_makers.id having count ( * ) > 3

Question: What are the id and names of the countries which have more than 3 car makers or produce the 'fiat' model?
SQL: select countries.countryid , countries.countryname from countries join car_makers on countries.countryid = car_makers.country group by countries.countryid having count ( * ) > 3 union select countries.countryid , countries.countryname from countries join car_makers on countries.countryid = car_makers.country join model_list on car_makers.id = model_list.maker where model_list.model = 'fiat'

Question: What are the ids and names of all countries that either have more than 3 car makers or produce fiat model ?
SQL: select countries.countryid , countries.countryname from countries join car_makers on countries.countryid = car_makers.country group by countries.countryid having count ( * ) > 3 union select countries.countryid , countries.countryname from countries join car_makers on countries.countryid = car_makers.country join model_list on car_makers.id = model_list.maker where model_list.model = 'fiat'