SQL
stringlengths
18
577
question
stringlengths
317
11.5k
SELECT T2.school_name , T1.budgeted , T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. Show each school name, its budgeted amount, and invested amount in year 2002 or after.
SELECT DISTINCT donator_name FROM endowment
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. Show all donor names.
SELECT count(*) FROM budget WHERE budgeted < invested
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. How many budget record has a budget amount smaller than the invested amount?
SELECT sum(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. What is the total budget amount for school "Glenn" in all years?
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING sum(T1.budgeted) > 100 OR sum(T3.amount) > 10
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.
SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING count(*) > 1
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. Find the names of schools that have more than one donator with donation amount above 8.5.
SELECT count(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING count(*) > 1)
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. Find the number of schools that have more than one donator whose donation amount is less than 8.5.
SELECT T1.School_name , T1.Mascot , T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested , T2.total_budget_percent_budgeted
Given the Table school having columns as School_id has datatype text, School_name has datatype text, Location has datatype text, Mascot has datatype text, Enrollment has datatype number, IHSAA_Class has datatype text, IHSAA_Football_Class has datatype text, County has datatype text which has School_id and Given the Table budget having columns as School_id has datatype number, Year has datatype number, Budgeted has datatype number, total_budget_percent_budgeted has datatype number, Invested has datatype number, total_budget_percent_invested has datatype number, Budget_invested_percent has datatype text which has School_id and Given the Table endowment having columns as endowment_id has datatype number, School_id has datatype number, donator_name has datatype text, amount has datatype number which has endowment_id. Answer the question by writing the appropriate SQL code. List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.
SELECT count(*) FROM building
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. How many buildings are there?
SELECT name , street_address , floors FROM building ORDER BY floors
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the name, street address, and number of floors for all buildings ordered by the number of floors.
SELECT name FROM building ORDER BY height_feet DESC LIMIT 1
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. What is the name of the tallest building?
SELECT avg(floors) , max(floors) , min(floors) FROM building
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. What are the average, maximum, and minimum number of floors for all buildings?
SELECT count(*) FROM building WHERE height_feet > (SELECT avg(height_feet) FROM building) OR floors > (SELECT avg(floors) FROM building)
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the number of buildings with a height above the average or a number of floors above the average.
SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. List the names of buildings with at least 200 feet of height and with at least 20 floors.
SELECT institution , LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private'
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the names and locations of institutions that are founded after 1990 and have the type "Private".
SELECT TYPE , count(*) , sum(enrollment) FROM institution GROUP BY TYPE
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show institution types, along with the number of institutions and total enrollment for each type.
SELECT TYPE FROM institution GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the institution type with the largest number of institutions.
SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.
SELECT name FROM building WHERE building_id NOT IN (SELECT building_id FROM institution)
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the name of buildings that do not have any institution.
SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the names of buildings except for those having an institution founded in 2003.
SELECT T1.name , count(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. For each building, show the name of the building and the number of institutions in it.
SELECT T1.name , T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING count(*) >= 2
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the names and heights of buildings with at least two institutions founded after 1880.
SELECT DISTINCT TYPE FROM institution
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show all the distinct institution types.
SELECT T1.institution , count(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show institution names along with the number of proteins for each institution.
SELECT count(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private'
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?
SELECT T2.protein_name , T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. Show the protein name and the institution name.
SELECT count(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. How many proteins are associated with an institution in a building with at least 20 floors?
SELECT count(*) FROM institution WHERE institution_id NOT IN (SELECT institution_id FROM protein)
Given the Table building having columns as building_id has datatype text, Name has datatype text, Street_address has datatype text, Years_as_tallest has datatype text, Height_feet has datatype number, Floors has datatype number which has building_id and Given the Table institution having columns as Institution_id has datatype text, Institution has datatype text, Location has datatype text, Founded has datatype number, Type has datatype text, Enrollment has datatype number, Team has datatype text, Primary_Conference has datatype text, building_id has datatype text which has Institution_id and Given the Table protein having columns as common_name has datatype text, protein_name has datatype text, divergence_from_human_lineage has datatype number, accession_number has datatype text, sequence_length has datatype number, sequence_identity_to_human_protein has datatype text, Institution_id has datatype text which has common_name. Answer the question by writing the appropriate SQL code. How many institutions do not have an associated protein in our record?
SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show all the locations where no cinema has capacity over 800.
SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show all the locations where some cinemas were opened in both year 2010 and year 2011.
SELECT count(*) FROM cinema
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. How many cinema do we have?
SELECT count(*) FROM cinema
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Count the number of cinemas.
SELECT name , openning_year , capacity FROM cinema
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show name, opening year, and capacity for each cinema.
SELECT name , LOCATION FROM cinema WHERE capacity > (SELECT avg(capacity) FROM cinema)
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show the cinema name and location for cinemas with capacity above average.
SELECT DISTINCT LOCATION FROM cinema
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What are all the locations with a cinema?
SELECT DISTINCT LOCATION FROM cinema
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Find the distinct locations that has a cinema.
SELECT name , openning_year FROM cinema ORDER BY openning_year DESC
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show all the cinema names and opening years in descending order of opening year.
SELECT name , LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What are the name and location of the cinema with the largest capacity?
SELECT avg(capacity) , min(capacity) , max(capacity) FROM cinema WHERE openning_year >= 2011
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.
SELECT LOCATION , count(*) FROM cinema GROUP BY LOCATION
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show each location and the number of cinemas there.
SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY count(*) DESC LIMIT 1
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What is the location with the most cinemas opened in year 2010 or later?
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) >= 2
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show all the locations with at least two cinemas with capacity above 300.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) >= 2
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Which locations have 2 or more cinemas with capacity over 300?
SELECT title , directed_by FROM film
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show the title and director for all films.
SELECT title , directed_by FROM film
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What are the title and director of each film?
SELECT DISTINCT directed_by FROM film
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show all directors.
SELECT DISTINCT directed_by FROM film
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Who are all the directors?
SELECT directed_by , count(*) FROM film GROUP BY directed_by
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. List all directors along with the number of films directed by each director.
SELECT T2.name , sum(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What is total number of show times per dat for each cinema?
SELECT T2.title , max(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What are the title and maximum price of each film?
SELECT T2.title , max(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Give me the title and highest price for each film.
SELECT T3.name , T2.title , T1.date , T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show cinema name, film title, date, and price for each record in schedule.
SELECT title , directed_by FROM film WHERE film_id NOT IN (SELECT film_id FROM schedule)
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. What are the title and director of the films without any schedule?
SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY sum(T1.show_times_per_day) DESC LIMIT 1
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Show director with the largest number of show times in total.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Find the locations that have more than one movie theater with capacity above 300.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. In which locations are there more than one movie theater with capacity above 300?
SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. How many films have the word 'Dummy' in their titles?
SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
Given the Table film having columns as Film_ID has datatype number, Rank_in_series has datatype number, Number_in_season has datatype number, Title has datatype text, Directed_by has datatype text, Original_air_date has datatype text, Production_code has datatype text which has Film_ID and Given the Table cinema having columns as Cinema_ID has datatype number, Name has datatype text, Openning_year has datatype number, Capacity has datatype number, Location has datatype text which has Cinema_ID and Given the Table schedule having columns as Cinema_ID has datatype number, Film_ID has datatype number, Date has datatype text, Show_times_per_day has datatype number, Price has datatype number which has Cinema_ID. Answer the question by writing the appropriate SQL code. Count the number of films whose title contains the word 'Dummy'.
SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. Are the customers holding coupons with amount 500 bad or good?
SELECT T1.customer_id , T1.first_name , count(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. How many bookings did each customer make? List the customer id, first name, and the count.
SELECT customer_id , sum(amount_paid) FROM Payments GROUP BY customer_id ORDER BY sum(amount_paid) DESC LIMIT 1
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What is the maximum total amount paid by a customer? List the customer id and amount.
SELECT T1.booking_id , T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY count(*) DESC LIMIT 1
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the id and the amount of refund of the booking that incurred the most times of payments?
SELECT product_id FROM products_booked GROUP BY product_id HAVING count(*) = 3
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What is the id of the product that is booked for 3 times?
SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What is the product description of the product booked with an amount of 102.76?
SELECT T3.booking_start_date , T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A'
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the start date and end date of the booking that has booked the product named 'Book collection A'?
SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the names of products whose availability equals to 1?
SELECT count(DISTINCT product_type_code) FROM products_for_hire
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. How many different product types are there?
SELECT first_name , last_name , gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the first name, last name, and gender of all the good customers? Order by their last name.
SELECT avg(amount_due) FROM payments
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What is the average amount due for all the payments?
SELECT max(booked_count) , min(booked_count) , avg(booked_count) FROM products_booked
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the maximum, minimum, and average booked count for the products booked?
SELECT DISTINCT payment_type_code FROM payments
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are all the distinct payment types?
SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%'
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the daily hire costs for the products with substring 'Book' in its name?
SELECT count(*) FROM Products_for_hire WHERE product_id NOT IN ( SELECT product_id FROM products_booked WHERE booked_amount > 200 )
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. How many products are never booked with amount higher than 200?
SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad'
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the coupon amount of the coupons owned by both good and bad customers?
SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check'
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'
SELECT product_name , product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20
Given the Table discount coupons having columns as coupon_id has datatype number, date_issued has datatype time, coupon_amount has datatype number which has coupon_id and Given the Table customers having columns as customer_id has datatype number, coupon_id has datatype number, good_or_bad_customer has datatype text, first_name has datatype text, last_name has datatype text, gender_mf has datatype text, date_became_customer has datatype time, date_last_hire has datatype time which has customer_id and Given the Table bookings having columns as booking_id has datatype number, customer_id has datatype number, booking_status_code has datatype text, returned_damaged_yn has datatype text, booking_start_date has datatype time, booking_end_date has datatype time, count_hired has datatype text, amount_payable has datatype number, amount_of_discount has datatype number, amount_outstanding has datatype number, amount_of_refund has datatype number which has booking_id and Given the Table products for hire having columns as product_id has datatype number, product_type_code has datatype text, daily_hire_cost has datatype number, product_name has datatype text, product_description has datatype text which has product_id and Given the Table payments having columns as payment_id has datatype number, booking_id has datatype number, customer_id has datatype number, payment_type_code has datatype text, amount_paid_in_full_yn has datatype text, payment_date has datatype time, amount_due has datatype number, amount_paid has datatype number which has payment_id and Given the Table products booked having columns as booking_id has datatype number, product_id has datatype number, returned_yn has datatype text, returned_late_yn has datatype text, booked_count has datatype number, booked_amount has datatype number which has booking_id and Given the Table view product availability having columns as product_id has datatype number, booking_id has datatype number, status_date has datatype time, available_yn has datatype text which has status_date. Answer the question by writing the appropriate SQL code. What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?
SELECT count(*) FROM phone
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. How many phones are there?
SELECT Name FROM phone ORDER BY Price ASC
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. List the names of phones in ascending order of price.
SELECT Memory_in_G , Carrier FROM phone
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. What are the memories and carriers of phones?
SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. List the distinct carriers of phones with memories bigger than 32.
SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile"
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the names of phones with carrier either "Sprint" or "TMobile".
SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. What is the carrier of the most expensive phone?
SELECT Carrier , COUNT(*) FROM phone GROUP BY Carrier
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show different carriers of phones together with the number of phones with each carrier.
SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the most frequently used carrier of the phones.
SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.
SELECT T3.Name , T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the names of phones and the districts of markets they are on.
SELECT T3.Name , T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.
SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the names of phones that are on market with number of shops greater than 50.
SELECT T2.Name , sum(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. For each phone, show its names and total number of stocks.
SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING sum(T1.Num_of_stock) >= 2000 ORDER BY sum(T1.Num_of_stock) DESC
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.
SELECT Name FROM phone WHERE Phone_id NOT IN (SELECT Phone_ID FROM phone_market)
Given the Table phone having columns as Name has datatype text, Phone_ID has datatype number, Memory_in_G has datatype number, Carrier has datatype text, Price has datatype number which has Phone_ID and Given the Table market having columns as Market_ID has datatype number, District has datatype text, Num_of_employees has datatype number, Num_of_shops has datatype number, Ranking has datatype number which has Market_ID and Given the Table phone market having columns as Market_ID has datatype number, Phone_ID has datatype text, Num_of_stock has datatype number which has Market_ID. Answer the question by writing the appropriate SQL code. List the names of phones that are not on any market.
SELECT count(*) FROM company
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. How many gas companies are there?
SELECT count(*) FROM company
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. What is the total number of companies?
SELECT company , rank FROM company ORDER BY Sales_billion DESC
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. List the company name and rank for all companies in the decreasing order of their sales.
SELECT company , rank FROM company ORDER BY Sales_billion DESC
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. What is the name and rank of every company ordered by descending number of sales?
SELECT company , main_industry FROM company WHERE headquarters != 'USA'
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. Show the company name and the main industry for all companies whose headquarters are not from USA.
SELECT company , main_industry FROM company WHERE headquarters != 'USA'
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. What are the companies and main industries of all companies that are not headquartered in the United States?
SELECT company , headquarters FROM company ORDER BY market_value DESC
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. Show all company names and headquarters in the descending order of market value.
SELECT company , headquarters FROM company ORDER BY market_value DESC
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. What are the names and headquarters of all companies ordered by descending market value?
SELECT min(market_value) , max(market_value) , avg(market_value) FROM company
Given the Table company having columns as Company_ID has datatype number, Rank has datatype number, Company has datatype text, Headquarters has datatype text, Main_Industry has datatype text, Sales_billion has datatype number, Profits_billion has datatype number, Assets_billion has datatype number, Market_Value has datatype number which has Company_ID and Given the Table gas station having columns as Station_ID has datatype number, Open_Year has datatype number, Location has datatype text, Manager_Name has datatype text, Vice_Manager_Name has datatype text, Representative_Name has datatype text which has Station_ID and Given the Table station company having columns as Station_ID has datatype number, Company_ID has datatype number, Rank_of_the_Year has datatype number which has Station_ID. Answer the question by writing the appropriate SQL code. Show minimum, maximum, and average market value for all companies.