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