db_name
stringclasses
146 values
prompt
stringlengths
310
4.81k
products_gen_characteristics
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Ref_Characteristic_Types ( characteristic_type_code, characteristic_type_description ) # Ref_Colors ( color_code, color_description ) # Ref_Product_Categories ( product_category_code, product_category_description, unit_of_measure ) # Characteristics ( characteristic_id, characteristic_type_code, characteristic_data_type, characteristic_name, other_characteristic_details ) # Products ( product_id, color_code, product_category_code, product_name, typical_buying_price, typical_selling_price, product_description, other_product_details ) # Product_Characteristics ( product_id, characteristic_id, product_characteristic_value ) # # Characteristics.characteristic_type_code can be joined with Ref_Characteristic_Types.characteristic_type_code # Products.color_code can be joined with Ref_Colors.color_code # Products.product_category_code can be joined with Ref_Product_Categories.product_category_code # Product_Characteristics.product_id can be joined with Products.product_id # Product_Characteristics.characteristic_id can be joined with Characteristics.characteristic_id # ### Question: # # How many colors are never used by any product? # ### SQL: # # SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products ) # ### End.
products_gen_characteristics
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Ref_Characteristic_Types ( characteristic_type_code, characteristic_type_description ) # Ref_Colors ( color_code, color_description ) # Ref_Product_Categories ( product_category_code, product_category_description, unit_of_measure ) # Characteristics ( characteristic_id, characteristic_type_code, characteristic_data_type, characteristic_name, other_characteristic_details ) # Products ( product_id, color_code, product_category_code, product_name, typical_buying_price, typical_selling_price, product_description, other_product_details ) # Product_Characteristics ( product_id, characteristic_id, product_characteristic_value ) # # Characteristics.characteristic_type_code can be joined with Ref_Characteristic_Types.characteristic_type_code # Products.color_code can be joined with Ref_Colors.color_code # Products.product_category_code can be joined with Ref_Product_Categories.product_category_code # Product_Characteristics.product_id can be joined with Products.product_id # Product_Characteristics.characteristic_id can be joined with Characteristics.characteristic_id # ### Question: # # Count the number of colors that are not used in any products. # ### SQL: # # SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products ) # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # How many events are there? # ### SQL: # # SELECT count(*) FROM event # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # List all the event names by year from the most recent to the oldest. # ### SQL: # # SELECT name FROM event ORDER BY YEAR DESC # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # What is the name of the event that happened in the most recent year? # ### SQL: # # SELECT name FROM event ORDER BY YEAR DESC LIMIT 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # How many stadiums are there? # ### SQL: # # SELECT count(*) FROM stadium # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the name of the stadium that has the maximum capacity. # ### SQL: # # SELECT name FROM stadium ORDER BY capacity DESC LIMIT 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of stadiums whose capacity is smaller than the average capacity. # ### SQL: # # SELECT name FROM stadium WHERE capacity < (SELECT avg(capacity) FROM stadium) # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the country that has the most stadiums. # ### SQL: # # SELECT country FROM stadium GROUP BY country ORDER BY count(*) DESC LIMIT 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Which country has at most 3 stadiums listed? # ### SQL: # # SELECT country FROM stadium GROUP BY country HAVING count(*) <= 3 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Which country has both stadiums with capacity greater than 60000 and stadiums with capacity less than 50000? # ### SQL: # # SELECT country FROM stadium WHERE capacity > 60000 INTERSECT SELECT country FROM stadium WHERE capacity < 50000 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # How many cities have a stadium that was opened before the year of 2006? # ### SQL: # # SELECT count(DISTINCT city) FROM stadium WHERE opening_year < 2006 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # How many stadiums does each country have? # ### SQL: # # SELECT country , count(*) FROM stadium GROUP BY country # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Which countries do not have a stadium that was opened after 2006? # ### SQL: # # SELECT country FROM stadium EXCEPT SELECT country FROM stadium WHERE opening_year > 2006 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # How many stadiums are not in country "Russia"? # ### SQL: # # SELECT count(*) FROM stadium WHERE country != 'Russia' # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of all swimmers, sorted by their 100 meter scores in ascending order. # ### SQL: # # SELECT name FROM swimmer ORDER BY meter_100 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # How many different countries are all the swimmers from? # ### SQL: # # SELECT count(DISTINCT nationality) FROM swimmer # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # List countries that have more than one swimmer. # ### SQL: # # SELECT nationality , count(*) FROM swimmer GROUP BY nationality HAVING count(*) > 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find all 200 meter and 300 meter results of swimmers with nationality "Australia". # ### SQL: # # SELECT meter_200 , meter_300 FROM swimmer WHERE nationality = 'Australia' # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of swimmers who has a result of "win". # ### SQL: # # SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # What is the name of the stadium which held the most events? # ### SQL: # # SELECT t1.name FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the name and capacity of the stadium where the event named "World Junior" happened. # ### SQL: # # SELECT t1.name , t1.capacity FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id WHERE t2.name = 'World Junior' # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of stadiums which have never had any event. # ### SQL: # # SELECT name FROM stadium WHERE id NOT IN (SELECT stadium_id FROM event) # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the name of the swimmer who has the most records. # ### SQL: # # SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id ORDER BY count(*) DESC LIMIT 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the name of the swimmer who has at least 2 records. # ### SQL: # # SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id HAVING count(*) >= 2 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the name and nationality of the swimmer who has won (i.e., has a result of "win") more than 1 time. # ### SQL: # # SELECT t1.name , t1.nationality FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' GROUP BY t2.swimmer_id HAVING count(*) > 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of the swimmers who have no record. # ### SQL: # # SELECT name FROM swimmer WHERE id NOT IN (SELECT swimmer_id FROM record) # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of the swimmers who have both "win" and "loss" results in the record. # ### SQL: # # SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' INTERSECT SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Loss' # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of stadiums that some Australian swimmers have been to. # ### SQL: # # SELECT t4.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id JOIN event AS t3 ON t2.event_id = t3.id JOIN stadium AS t4 ON t4.id = t3.stadium_id WHERE t1.nationality = 'Australia' # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find the names of stadiums that the most swimmers have been to. # ### SQL: # # SELECT t3.name FROM record AS t1 JOIN event AS t2 ON t1.event_id = t2.id JOIN stadium AS t3 ON t3.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1 # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # Find all details for each swimmer. # ### SQL: # # SELECT * FROM swimmer # ### End.
swimming
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # swimmer ( ID, name, Nationality, meter_100, meter_200, meter_300, meter_400, meter_500, meter_600, meter_700, Time ) # stadium ( ID, name, Capacity, City, Country, Opening_year ) # event ( ID, Name, Stadium_ID, Year ) # record ( ID, Result, Swimmer_ID, Event_ID ) # # event.Stadium_ID can be joined with stadium.ID # record.Swimmer_ID can be joined with swimmer.ID # record.Event_ID can be joined with event.ID # ### Question: # # What is the average capacity of the stadiums that were opened in year 2005? # ### SQL: # # SELECT avg(capacity) FROM stadium WHERE opening_year = 2005 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # How many railways are there? # ### SQL: # # SELECT count(*) FROM railway # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # List the builders of railways in ascending alphabetical order. # ### SQL: # # SELECT Builder FROM railway ORDER BY Builder ASC # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # List the wheels and locations of the railways. # ### SQL: # # SELECT Wheels , LOCATION FROM railway # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # What is the maximum level of managers in countries that are not "Australia"? # ### SQL: # # SELECT max(LEVEL) FROM manager WHERE Country != "Australia " # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # What is the average age for all managers? # ### SQL: # # SELECT avg(Age) FROM manager # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # What are the names of managers in ascending order of level? # ### SQL: # # SELECT Name FROM manager ORDER BY LEVEL ASC # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # What are the names and arrival times of trains? # ### SQL: # # SELECT Name , Arrival FROM train # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # What is the name of the oldest manager? # ### SQL: # # SELECT Name FROM manager ORDER BY Age DESC LIMIT 1 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the names of trains and locations of railways they are in. # ### SQL: # # SELECT T2.Name , T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the builder of railways associated with the trains named "Andaman Exp". # ### SQL: # # SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID WHERE T2.Name = "Andaman Exp" # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show id and location of railways that are associated with more than one train. # ### SQL: # # SELECT T2.Railway_ID , T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*) > 1 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the id and builder of the railway that are associated with the most trains. # ### SQL: # # SELECT T2.Railway_ID , T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show different builders of railways, along with the corresponding number of railways using each builder. # ### SQL: # # SELECT Builder , COUNT(*) FROM railway GROUP BY Builder # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the most common builder of railways. # ### SQL: # # SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show different locations of railways along with the corresponding number of railways at each location. # ### SQL: # # SELECT LOCATION , COUNT(*) FROM railway GROUP BY LOCATION # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the locations that have more than one railways. # ### SQL: # # SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*) > 1 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # List the object number of railways that do not have any trains. # ### SQL: # # SELECT ObjectNumber FROM railway WHERE Railway_ID NOT IN (SELECT Railway_ID FROM train) # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the countries that have both managers of age above 50 and managers of age below 46. # ### SQL: # # SELECT Country FROM manager WHERE Age > 50 INTERSECT SELECT Country FROM manager WHERE Age < 46 # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the distinct countries of managers. # ### SQL: # # SELECT DISTINCT Country FROM manager # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the working years of managers in descending order of their level. # ### SQL: # # SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC # ### End.
railway
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # railway ( Railway_ID, Railway, Builder, Built, Wheels, Location, ObjectNumber ) # train ( Train_ID, Train_Num, Name, From, Arrival, Railway_ID ) # manager ( Manager_ID, Name, Country, Working_year_starts, Age, Level ) # railway_manage ( Railway_ID, Manager_ID, From_Year ) # # train.Railway_ID can be joined with railway.Railway_ID # railway_manage.Railway_ID can be joined with railway.Railway_ID # railway_manage.Manager_ID can be joined with manager.Manager_ID # ### Question: # # Show the countries that have managers of age above 50 or below 46. # ### SQL: # # SELECT Country FROM manager WHERE Age > 50 OR Age < 46 # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # How many addresses are there in country USA? # ### SQL: # # SELECT count(*) FROM addresses WHERE country = 'USA' # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show all distinct cities in the address record. # ### SQL: # # SELECT DISTINCT city FROM addresses # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show each state and the number of addresses in each state. # ### SQL: # # SELECT state_province_county , count(*) FROM addresses GROUP BY state_province_county # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show names and phones of customers who do not have address information. # ### SQL: # # SELECT customer_name , customer_phone FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history) # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the name of the customer who has the most orders. # ### SQL: # # SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1 # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the product type codes which have at least two products. # ### SQL: # # SELECT product_type_code FROM products GROUP BY product_type_code HAVING count(*) >= 2 # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the names of customers who have both an order in completed status and an order in part status. # ### SQL: # # SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Part' # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the name, phone, and payment method code for all customers in descending order of customer number. # ### SQL: # # SELECT customer_name , customer_phone , payment_method_code FROM customers ORDER BY customer_number DESC # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the product name and total order quantity for each product. # ### SQL: # # SELECT T1.product_name , sum(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_id # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the minimum, maximum, average price for all products. # ### SQL: # # SELECT min(product_price) , max(product_price) , avg(product_price) FROM products # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # How many products have a price higher than the average? # ### SQL: # # SELECT count(*) FROM products WHERE product_price > (SELECT avg(product_price) FROM products) # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the customer name, customer address city, date from, and date to for each customer address history. # ### SQL: # # SELECT T2.customer_name , T3.city , T1.date_from , T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id JOIN addresses AS T3 ON T1.address_id = T3.address_id # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the names of customers who use Credit Card payment method and have more than 2 orders. # ### SQL: # # SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.payment_method_code = 'Credit Card' GROUP BY T1.customer_id HAVING count(*) > 2 # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # What are the name and phone of the customer with the most ordered product quantity? # ### SQL: # # SELECT T1.customer_name , T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T3.order_id = T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC LIMIT 1 # ### End.
customers_and_products_contacts
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Addresses ( address_id, line_1_number_building, city, zip_postcode, state_province_county, country ) # Products ( product_id, product_type_code, product_name, product_price ) # Customers ( customer_id, payment_method_code, customer_number, customer_name, customer_address, customer_phone, customer_email ) # Contacts ( contact_id, customer_id, gender, first_name, last_name, contact_phone ) # Customer_Address_History ( customer_id, address_id, date_from, date_to ) # Customer_Orders ( order_id, customer_id, order_date, order_status_code ) # Order_Items ( order_item_id, order_id, product_id, order_quantity ) # # Customer_Address_History.address_id can be joined with Addresses.address_id # Customer_Address_History.customer_id can be joined with Customers.customer_id # Customer_Orders.customer_id can be joined with Customers.customer_id # Order_Items.order_id can be joined with Customer_Orders.order_id # Order_Items.product_id can be joined with Products.product_id # ### Question: # # Show the product type and name for the products with price higher than 1000 or lower than 500. # ### SQL: # # SELECT product_type_code , product_name FROM products WHERE product_price > 1000 OR product_price < 500 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the name of dorms only for female (F gender). # ### SQL: # # SELECT dorm_name FROM dorm WHERE gender = 'F' # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What are the names of the all-female dorms? # ### SQL: # # SELECT dorm_name FROM dorm WHERE gender = 'F' # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the name of dorms that can accommodate more than 300 students. # ### SQL: # # SELECT dorm_name FROM dorm WHERE student_capacity > 300 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What are the names of all the dorms that can accomdate more than 300 students? # ### SQL: # # SELECT dorm_name FROM dorm WHERE student_capacity > 300 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many female students (sex is F) whose age is below 25? # ### SQL: # # SELECT count(*) FROM student WHERE sex = 'F' AND age < 25 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many girl students who are younger than 25? # ### SQL: # # SELECT count(*) FROM student WHERE sex = 'F' AND age < 25 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the first name of students who is older than 20. # ### SQL: # # SELECT fname FROM student WHERE age > 20 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What are the first names of all students who are older than 20? # ### SQL: # # SELECT fname FROM student WHERE age > 20 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the first name of students living in city PHL whose age is between 20 and 25. # ### SQL: # # SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What is the first name of the students who are in age 20 to 25 and living in PHL city? # ### SQL: # # SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many dorms are there? # ### SQL: # # SELECT count(*) FROM dorm # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many dorms are in the database? # ### SQL: # # SELECT count(*) FROM dorm # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the number of distinct amenities. # ### SQL: # # SELECT count(*) FROM dorm_amenity # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many diffrent dorm amenities are there? # ### SQL: # # SELECT count(*) FROM dorm_amenity # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the total capacity of all dorms. # ### SQL: # # SELECT sum(student_capacity) FROM dorm # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What is the total student capacity of all dorms? # ### SQL: # # SELECT sum(student_capacity) FROM dorm # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many students are there? # ### SQL: # # SELECT count(*) FROM student # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many students exist? # ### SQL: # # SELECT count(*) FROM student # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the average age of all students living in the each city. # ### SQL: # # SELECT avg(age) , city_code FROM student GROUP BY city_code # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What is the average age for each city and what are those cities? # ### SQL: # # SELECT avg(age) , city_code FROM student GROUP BY city_code # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the average and total capacity of dorms for the students with gender X. # ### SQL: # # SELECT avg(student_capacity) , sum(student_capacity) FROM dorm WHERE gender = 'X' # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What is the average and total capacity for all dorms who are of gender X? # ### SQL: # # SELECT avg(student_capacity) , sum(student_capacity) FROM dorm WHERE gender = 'X' # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the number of dorms that have some amenity. # ### SQL: # # SELECT count(DISTINCT dormid) FROM has_amenity # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many dorms have amenities? # ### SQL: # # SELECT count(DISTINCT dormid) FROM has_amenity # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the name of dorms that do not have any amenity # ### SQL: # # SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity) # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What are the names of all the dorms that don't have any amenities? # ### SQL: # # SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity) # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the number of distinct gender for dorms. # ### SQL: # # SELECT count(DISTINCT gender) FROM dorm # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # How many different genders are there in the dorms? # ### SQL: # # SELECT count(DISTINCT gender) FROM dorm # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the capacity and gender type of the dorm whose name has substring ‘Donor’. # ### SQL: # # SELECT student_capacity , gender FROM dorm WHERE dorm_name LIKE '%Donor%' # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What is the student capacity and type of gender for the dorm whose name as the phrase Donor in it? # ### SQL: # # SELECT student_capacity , gender FROM dorm WHERE dorm_name LIKE '%Donor%' # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # Find the name and gender type of the dorms whose capacity is greater than 300 or less than 100. # ### SQL: # # SELECT dorm_name , gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100 # ### End.
dorm_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Dorm ( dormid, dorm_name, student_capacity, gender ) # Dorm_amenity ( amenid, amenity_name ) # Has_amenity ( dormid, amenid ) # Lives_in ( stuid, dormid, room_number ) # # Has_amenity.amenid can be joined with Dorm_amenity.amenid # Has_amenity.dormid can be joined with Dorm.dormid # Lives_in.dormid can be joined with Dorm.dormid # Lives_in.stuid can be joined with Student.StuID # ### Question: # # What are the names and types of the dorms that have a capacity greater than 300 or less than 100? # ### SQL: # # SELECT dorm_name , gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100 # ### End.