input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: Calculate the percentage of households in residential areas of countries over 10000. [/INST]
SELECT CAST(COUNT(CASE WHEN T2.households > 10000 THEN T1.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T1.zip_code) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code;
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: Among the types of postal points in Saint Croix, what percentage of postal points is the post office? [/INST]
SELECT CAST(COUNT(CASE WHEN T2.type = 'Post Office' THEN T1.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T1.zip_code) FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.county = 'SAINT CROIX';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: Among the area code 787, list the country of the cities with a postal point type of unique postal office. [/INST]
SELECT DISTINCT T2.county FROM area_code AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code INNER JOIN zip_data AS T3 ON T1.zip_code = T3.zip_code WHERE T1.area_code = '787' AND T3.type = 'Unique Post Office';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA alias : zip_code [ INTEGER ] primary_key alias.zip_code = zip_data.zip_code alias [ TEXT ] Please write me a SQL statement that answers the following question: What is the elevation of the city with the alias East Longmeadow? [/INST]
SELECT T2.elevation FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'East Longmeadow';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] Please write me a SQL statement that answers the following question: In cities that do not implement daylight savings, what is the total number of cities? [/INST]
SELECT COUNT(T1.area_code) FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.daylight_savings = 'No';
[INST] Here is a database schema: area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: Give the country and area code of the city with zip code 1116. [/INST]
SELECT T2.county, T1.area_code FROM area_code AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T1.zip_code = 1116;
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA alias : zip_code [ INTEGER ] primary_key alias.zip_code = zip_data.zip_code alias [ TEXT ] Please write me a SQL statement that answers the following question: Among the cities with alias St Thomas, provide the type of postal point for each city. [/INST]
SELECT DISTINCT T2.type FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'St Thomas';
[INST] Here is a database schema: state : abbreviation [ TEXT ] primary_key name [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: List down the names of the cities belonging to Noble, Oklahoma. [/INST]
SELECT T3.city FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state INNER JOIN zip_data AS T3 ON T2.zip_code = T3.zip_code WHERE T1.name = 'Oklahoma' AND T2.county = 'NOBLE';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] Please write me a SQL statement that answers the following question: Among the listed cities, provide the area code of the city with the largest water area. [/INST]
SELECT T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.water_area = ( SELECT MAX(water_area) FROM zip_data );
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA alias : zip_code [ INTEGER ] primary_key alias.zip_code = zip_data.zip_code alias [ TEXT ] Please write me a SQL statement that answers the following question: Provide the alias of the city with the highest population in year 2020. [/INST]
SELECT T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.population_2020 = ( SELECT MAX(population_2020) FROM zip_data );
[INST] Here is a database schema: state : abbreviation [ TEXT ] primary_key name [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: What is the elevation of the city belonging to Hampden, Massachusetts? [/INST]
SELECT T3.elevation FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state INNER JOIN zip_data AS T3 ON T2.zip_code = T3.zip_code WHERE T1.name = 'Massachusetts' AND T2.county = 'HAMPDEN' GROUP BY T3.elevation;
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] Please write me a SQL statement that answers the following question: List the area code of the city with the highest Hispanic population. [/INST]
SELECT T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.hispanic_population = ( SELECT MAX(hispanic_population) FROM zip_data );
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA alias : zip_code [ INTEGER ] primary_key alias.zip_code = zip_data.zip_code alias [ TEXT ] Please write me a SQL statement that answers the following question: Give the alias of the cities with an Asian population of 7. [/INST]
SELECT T1.alias FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.asian_population = 7;
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average of the white population in the cities with area code 920? [/INST]
SELECT AVG(T2.white_population) FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.area_code = 920;
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA alias : zip_code [ INTEGER ] primary_key alias.zip_code = zip_data.zip_code alias [ TEXT ] Please write me a SQL statement that answers the following question: Among the cities with alias Ponce, what is the percentage of cities with a country level FIPS code of less than 20? [/INST]
SELECT CAST(COUNT(CASE WHEN T2.county_fips < 20 THEN T2.zip_code ELSE NULL END) AS REAL) * 100 / COUNT(T2.zip_code) FROM alias AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.alias = 'Ponce';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: List down the country of the cities with a population greater than 97% of the average population of all countries in 2020. [/INST]
SELECT T1.county FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.population_2020 > 0.97 * ( SELECT AVG(population_2020) FROM zip_data );
[INST] Here is a database schema: congress : cognress_rep_id [ TEXT ] primary_key first_name [ TEXT ] last_name [ TEXT ] CID [ TEXT ] party [ TEXT ] state [ TEXT ] abbreviation [ TEXT ] congress.abbreviation = state.abbreviation House [ TEXT ] District [ INTEGER ] land_area [ REAL ] zip_congress : zip_code [ INTEGER ] zip_congress.zip_code = zip_data.zip_code district [ TEXT ] zip_congress.district = congress.cognress_rep_id Please write me a SQL statement that answers the following question: Count the number of postal points in the district represented by Kirkpatrick Ann. [/INST]
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.first_name = 'Kirkpatrick' AND T1.last_name = 'Ann';
[INST] Here is a database schema: CBSA : CBSA [ INTEGER ] primary_key CBSA_name [ TEXT ] CBSA_type [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA Please write me a SQL statement that answers the following question: Provide the zip codes and coordinates of the postal points under Allentown-Bethlehem-Easton, PA-NJ. [/INST]
SELECT T2.zip_code, T2.latitude, T2.longitude FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'Allentown-Bethlehem-Easton, PA-NJ';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA avoid : zip_code [ INTEGER ] avoid.zip_code = zip_data.zip_code bad_alias [ TEXT ] Please write me a SQL statement that answers the following question: Provide the zip codes, cities, and locations of the postal points that have Shared Reshipper as a bad alias. [/INST]
SELECT T1.zip_code, T2.city, T2.latitude, T2.longitude FROM avoid AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T1.bad_alias = 'Shared Reshipper';
[INST] Here is a database schema: congress : cognress_rep_id [ TEXT ] primary_key first_name [ TEXT ] last_name [ TEXT ] CID [ TEXT ] party [ TEXT ] state [ TEXT ] abbreviation [ TEXT ] congress.abbreviation = state.abbreviation House [ TEXT ] District [ INTEGER ] land_area [ REAL ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA zip_congress : zip_code [ INTEGER ] zip_congress.zip_code = zip_data.zip_code district [ TEXT ] zip_congress.district = congress.cognress_rep_id Please write me a SQL statement that answers the following question: Who are the congress representatives of the postal points in Garfield? [/INST]
SELECT T3.first_name, T3.last_name FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code INNER JOIN congress AS T3 ON T2.district = T3.cognress_rep_id WHERE T1.city = 'Garfield';
[INST] Here is a database schema: CBSA : CBSA [ INTEGER ] primary_key CBSA_name [ TEXT ] CBSA_type [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA Please write me a SQL statement that answers the following question: Count the number of postal points under New York-Newark-Jersey City, NY-NJ-PA. [/INST]
SELECT COUNT(T2.zip_code) FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T1.CBSA_name = 'New York-Newark-Jersey City, NY-NJ-PA';
[INST] Here is a database schema: congress : cognress_rep_id [ TEXT ] primary_key first_name [ TEXT ] last_name [ TEXT ] CID [ TEXT ] party [ TEXT ] state [ TEXT ] abbreviation [ TEXT ] congress.abbreviation = state.abbreviation House [ TEXT ] District [ INTEGER ] land_area [ REAL ] zip_congress : zip_code [ INTEGER ] zip_congress.zip_code = zip_data.zip_code district [ TEXT ] zip_congress.district = congress.cognress_rep_id Please write me a SQL statement that answers the following question: How many postal points are there under the congress representative in Puerto Rico? [/INST]
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.state = 'Puerto Rico';
[INST] Here is a database schema: state : abbreviation [ TEXT ] primary_key name [ TEXT ] country : zip_code [ INTEGER ] country.zip_code = zip_data.zip_code county [ TEXT ] state [ TEXT ] country.state = state.abbreviation Please write me a SQL statement that answers the following question: Describe the number of postal points and the countries in West Virginia. [/INST]
SELECT COUNT(DISTINCT T2.zip_code), COUNT(DISTINCT T2.county) FROM state AS T1 INNER JOIN country AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'West Virginia';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA area_code : zip_code [ INTEGER ] area_code.zip_code = zip_data.zip_code area_code [ INTEGER ] Please write me a SQL statement that answers the following question: Provide the zip codes and area codes of the postal points with the community post office type at the elevation above 6000. [/INST]
SELECT T1.zip_code, T1.area_code FROM area_code AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code WHERE T2.type = 'Community Post Office ' AND T2.elevation > 6000;
[INST] Here is a database schema: congress : cognress_rep_id [ TEXT ] primary_key first_name [ TEXT ] last_name [ TEXT ] CID [ TEXT ] party [ TEXT ] state [ TEXT ] abbreviation [ TEXT ] congress.abbreviation = state.abbreviation House [ TEXT ] District [ INTEGER ] land_area [ REAL ] zip_congress : zip_code [ INTEGER ] zip_congress.zip_code = zip_data.zip_code district [ TEXT ] zip_congress.district = congress.cognress_rep_id Please write me a SQL statement that answers the following question: How many postal points are there under the congress representative from the House of Representatives in Mississippi? [/INST]
SELECT COUNT(T2.zip_code) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district WHERE T1.state = 'Mississippi';
[INST] Here is a database schema: zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA zip_congress : zip_code [ INTEGER ] zip_congress.zip_code = zip_data.zip_code district [ TEXT ] zip_congress.district = congress.cognress_rep_id Please write me a SQL statement that answers the following question: Provide the congress representatives' IDs of the postal points in East Springfield. [/INST]
SELECT T2.district FROM zip_data AS T1 INNER JOIN zip_congress AS T2 ON T1.zip_code = T2.zip_code WHERE T1.city = 'East Springfield';
[INST] Here is a database schema: CBSA : CBSA [ INTEGER ] primary_key CBSA_name [ TEXT ] CBSA_type [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA Please write me a SQL statement that answers the following question: Who is the CBSA officer of the post point in the area with the highest number of employees? [/INST]
SELECT T1.CBSA_name FROM CBSA AS T1 INNER JOIN zip_data AS T2 ON T1.CBSA = T2.CBSA WHERE T2.employees = ( SELECT MAX(employees) FROM zip_data );
[INST] Here is a database schema: state : abbreviation [ TEXT ] primary_key name [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA Please write me a SQL statement that answers the following question: How many postal points with unique post office types are there in Ohio? [/INST]
SELECT COUNT(T2.zip_code) FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Ohio' AND T2.type = 'Unique Post Office';
[INST] Here is a database schema: state : abbreviation [ TEXT ] primary_key name [ TEXT ] zip_data : zip_code [ INTEGER ] primary_key city [ TEXT ] state [ TEXT ] zip_data.state = state.abbreviation multi_county [ TEXT ] type [ TEXT ] organization [ TEXT ] time_zone [ TEXT ] daylight_savings [ TEXT ] latitude [ REAL ] longitude [ REAL ] elevation [ INTEGER ] state_fips [ INTEGER ] county_fips [ INTEGER ] region [ TEXT ] division [ TEXT ] population_2020 [ INTEGER ] population_2010 [ INTEGER ] households [ INTEGER ] avg_house_value [ INTEGER ] avg_income_per_household [ INTEGER ] persons_per_household [ REAL ] white_population [ INTEGER ] black_population [ INTEGER ] hispanic_population [ INTEGER ] asian_population [ INTEGER ] american_indian_population [ INTEGER ] hawaiian_population [ INTEGER ] other_population [ INTEGER ] male_population [ INTEGER ] female_population [ INTEGER ] median_age [ REAL ] male_median_age [ REAL ] female_median_age [ REAL ] residential_mailboxes [ INTEGER ] business_mailboxes [ INTEGER ] total_delivery_receptacles [ INTEGER ] businesses [ INTEGER ] 1st_quarter_payroll [ INTEGER ] annual_payroll [ INTEGER ] employees [ INTEGER ] water_area [ REAL ] land_area [ REAL ] single_family_delivery_units [ INTEGER ] multi_family_delivery_units [ INTEGER ] total_beneficiaries [ INTEGER ] retired_workers [ INTEGER ] disabled_workers [ INTEGER ] parents_and_widowed [ INTEGER ] spouses [ INTEGER ] children [ INTEGER ] over_65 [ INTEGER ] monthly_benefits_all [ INTEGER ] monthly_benefits_retired_workers [ INTEGER ] monthly_benefits_widowed [ INTEGER ] CBSA [ INTEGER ] zip_data.CBSA = CBSA.CBSA Please write me a SQL statement that answers the following question: Calculate the average number of beneficiaries per postal point in Guam. [/INST]
SELECT CAST(SUM(T2.total_beneficiaries) AS REAL) / COUNT(T2.zip_code) FROM state AS T1 INNER JOIN zip_data AS T2 ON T1.abbreviation = T2.state WHERE T1.name = 'Guam';
[INST] Here is a database schema: congress : cognress_rep_id [ TEXT ] primary_key first_name [ TEXT ] last_name [ TEXT ] CID [ TEXT ] party [ TEXT ] state [ TEXT ] abbreviation [ TEXT ] congress.abbreviation = state.abbreviation House [ TEXT ] District [ INTEGER ] land_area [ REAL ] zip_congress : zip_code [ INTEGER ] zip_congress.zip_code = zip_data.zip_code district [ TEXT ] zip_congress.district = congress.cognress_rep_id Please write me a SQL statement that answers the following question: Calculate the percentage of congress representatives from the Democrat party. Among them, how many postal points are in the Hawaii state? [/INST]
SELECT CAST(SUM(CASE WHEN T1.party = 'Democrat' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*), SUM(CASE WHEN T1.state = 'Hawaii' THEN 1 ELSE 0 END) FROM congress AS T1 INNER JOIN zip_congress AS T2 ON T1.cognress_rep_id = T2.district;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the root beer brand that has the longest history? [/INST]
SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear = ( SELECT MIN(FirstBrewedYear) FROM rootbeerbrand );
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: How many breweries are located in North America? [/INST]
SELECT COUNT(BrandID) FROM rootbeerbrand WHERE Country = 'United States';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: Please list the names of all the root beer brands that are advertised on facebook. [/INST]
SELECT BrandName FROM rootbeerbrand WHERE FacebookPage IS NOT NULL;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the root beer brand with the lowest unit profit available to wholesalers? [/INST]
SELECT BrandName FROM rootbeerbrand ORDER BY CurrentRetailPrice - WholesaleCost LIMIT 1;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: What is the description of the root beer brand A&W? [/INST]
SELECT Description FROM rootbeerbrand WHERE BrandName = 'A&W';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: In which city is the brewery AJ Stephans Beverages located? [/INST]
SELECT City FROM rootbeerbrand WHERE BreweryName = 'AJ Stephans Beverages';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Tell the number of reviews given by James House. [/INST]
SELECT COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.First = 'James' AND T1.Last = 'House';
[INST] Here is a database schema: geolocation : LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID Latitude [ REAL ] Longitude [ REAL ] location : LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID LocationName [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Please write me a SQL statement that answers the following question: State the coordinate of Sac State American River Courtyard. [/INST]
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State American River Courtyard';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Which customer has the most reviews? State the full name. [/INST]
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.CustomerID ORDER BY COUNT(T2.CustomerID) DESC LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: For the customer who leaves the review content of "Tastes like Australia.", when was his/her first purchase date? [/INST]
SELECT T1.FirstPurchaseDate FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Review = 'Tastes like Australia.';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: For the root beer brand with the most 5 star ratings, what is the name of the brewery? [/INST]
SELECT T1.BreweryName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 GROUP BY T1.BrandID ORDER BY COUNT(T2.StarRating) DESC LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: For the customer who gave a 3 star rating to Frostie brand on 2014/4/24, did the user permit the company to send regular emails to him/her? [/INST]
SELECT CASE WHEN T1.SubscribedToEmailList LIKE 'TRUE' THEN 'YES' ELSE 'NO' END AS result FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T2.StarRating = 3 AND T3.BrandName = 'Frostie' AND T2.ReviewDate = '2014-04-24';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: For the root beer brand which got the review with the content of "The quintessential dessert root beer. No ice cream required.", what is the current retail price of the root beer? [/INST]
SELECT T1.CurrentRetailPrice - T1.WholesaleCost AS price FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.Review = 'The quintessential dessert root beer. No ice cream required.';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the percentage of 5 star ratings River City brand root beer get? [/INST]
SELECT CAST(COUNT(CASE WHEN T2.StarRating = 5 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.StarRating) FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'River City';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the average number of reviews of all the root beer brands from "CA" State? [/INST]
SELECT CAST(COUNT(*) AS REAL) / COUNT(DISTINCT T1.BrandID) AS avgreview FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.State = 'CA';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] Please write me a SQL statement that answers the following question: How many female customers permit the company to send regular emails to them? [/INST]
SELECT COUNT(CustomerID) FROM customers WHERE Gender = 'F' AND SubscribedToEmailList = 'TRUE';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the brand of the beer with the shortest brewed history? [/INST]
SELECT BrandName FROM rootbeerbrand ORDER BY FirstBrewedYear DESC LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] Please write me a SQL statement that answers the following question: What are the full names of the first top 10 customers? [/INST]
SELECT First, Last FROM customers ORDER BY FirstPurchaseDate LIMIT 10;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: How many breweries are there in Australia? [/INST]
SELECT COUNT(BreweryName) FROM rootbeerbrand WHERE Country = 'Australia';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] Please write me a SQL statement that answers the following question: How many customers are named Charles in Sacramento? [/INST]
SELECT COUNT(CustomerID) FROM customers WHERE First = 'Charles' AND City = 'Sacramento';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Which brand of root beer did Jayne Collins give the lowest rating? [/INST]
SELECT T3.BrandName FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T1.First = 'Jayne' AND T1.Last = 'Collins' AND T2.StarRating = 1;
[INST] Here is a database schema: location : LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID LocationName [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: How many sweet bottled root beers that do not contain cane sugar were purchased in 2015 through the selling company located in Sac State American River Courtyard? [/INST]
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN location AS T3 ON T1.LocationID = T3.LocationID WHERE T3.LocationName = 'Sac State American River Courtyard' AND T1.PurchaseDate LIKE '2015%' AND T2.Honey = 'TRUE' AND T2.CaneSugar = 'FALSE' AND T1.ContainerType = 'Bottle';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Which brewery does the most purchased root beer in 2016 belong to? [/INST]
SELECT T2.BreweryName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.PurchaseDate BETWEEN '2016-01-01' AND '2016-12-31' GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What are the full names of the customer who gave River City a 5-star? [/INST]
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T3.BrandName = 'River City' AND T2.StarRating = 5;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Which brand of root beer was highly rated by customers? [/INST]
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Among the root beer brands that do not advertise on Facebook and Twitter, which brand has the highest number of purchases? [/INST]
SELECT T2.BreweryName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.FacebookPage IS NULL AND T2.Twitter IS NULL GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1;
[INST] Here is a database schema: location : LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID LocationName [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Between Sac State Union and Sac State American River Courtyard, which location sold the most Dog n Suds root beer? [/INST]
SELECT T3.LocationName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN location AS T3 ON T1.LocationID = T3.LocationID WHERE T2.BrandName = 'Dog n Suds' AND T3.LocationName IN ('Sac State American River Courtyard', 'Sac State Union') GROUP BY T1.LocationID ORDER BY COUNT(T1.BrandID) DESC LIMIT 1;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: How many canned A&W were purchased in 2016? [/INST]
SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.ContainerType = 'Can' AND T2.BrandName = 'A&W' AND T1.PurchaseDate LIKE '2016%';
[INST] Here is a database schema: geolocation : LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID Latitude [ REAL ] Longitude [ REAL ] location : LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID LocationName [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Please write me a SQL statement that answers the following question: What is the precise location of Sac State Union? [/INST]
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State Union';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What are the brands of the root beers that received 5-star ratings from no less than 5 customers? [/INST]
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 GROUP BY T2.BrandID HAVING COUNT(T2.StarRating) >= 5;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: List the brands of root beer produced by Dr Pepper Snapple Group and calculate their percentage of purchases between 2014 to 2016. [/INST]
SELECT T1.BrandName , CAST(SUM(CASE WHEN T2.PurchaseDate >= '2014-01-01' AND T2.PurchaseDate <= '2016-12-31' THEN 1 ELSE 0 END) AS REAL) / COUNT(T2.BrandID) AS purchase FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BreweryName = 'Dr Pepper Snapple Group' GROUP BY T2.BrandID;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] Please write me a SQL statement that answers the following question: List the full name and phone number of male customers from Fair Oaks who are subscribed to the email list. [/INST]
SELECT First, Last, PhoneNumber FROM customers WHERE Gender = 'M' AND City = 'Fair Oaks' AND SubscribedToEmailList = 'TRUE';
[INST] Here is a database schema: rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Among the root beer purchased in 2014, what percentage were sold in cans? [/INST]
SELECT CAST(COUNT(CASE WHEN ContainerType = 'Can' THEN RootBeerID ELSE NULL END) AS REAL) * 100 / COUNT(RootBeerID) FROM rootbeer WHERE PurchaseDate LIKE '2014%';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: Give the name of the brands that brewed their first drink between 1996 and 2000 in the descending order of the date brewed. [/INST]
SELECT BrandName FROM rootbeerbrand WHERE FirstBrewedYear BETWEEN '1996' AND '2000' ORDER BY FirstBrewedYear DESC;
[INST] Here is a database schema: rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Find the brand Id of the root beer which has the most number of customers who gave 1-star ratings. [/INST]
SELECT BrandID FROM rootbeerreview WHERE StarRating = 1 GROUP BY BrandID ORDER BY COUNT(BrandID) DESC LIMIT 1;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] Please write me a SQL statement that answers the following question: How many brands of root beers are available in cans and contain corn syrup and artificial sweeteners? [/INST]
SELECT COUNT(BrandID) FROM rootbeerbrand WHERE CornSyrup = 'TRUE' AND ArtificialSweetener = 'TRUE' AND AvailableInCans = 'TRUE';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Find the root beer with the most and least amount of profit per unit and list the container types in which these root beers are sold. [/INST]
SELECT * FROM ( SELECT T1.BrandName, T2.ContainerType FROM rootbeerbrand AS T1 INNER JOIN rootbeer AS T2 ON T1.BrandID = T2.BrandID ORDER BY T1.CurrentRetailPrice - T1.WholesaleCost DESC LIMIT 1 ) UNION ALL SELECT * FROM ( SELECT T3.BrandName, T4.ContainerType FROM rootbeerbrand AS T3 INNER JOIN rootbeer AS T4 ON T3.BrandID = T4.BrandID ORDER BY T3.CurrentRetailPrice - T3.WholesaleCost ASC LIMIT 1 );
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Among the customers not subscribed to the mailing list, what percentage has given three or more stars in a review? [/INST]
SELECT CAST(COUNT(CASE WHEN T2.StarRating > 3 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.SubscribedToEmailList = 'FALSE';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Which root beer got the most five stars in 2012? Give the brand name of this beer. [/INST]
SELECT T3.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID INNER JOIN rootbeerbrand AS T3 ON T1.BrandID = T3.BrandID WHERE T2.StarRating = 5 AND strftime('%Y', T2.ReviewDate) = '2012' GROUP BY T1.BrandID ORDER BY COUNT(T2.BrandID) DESC LIMIT 1;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: In the reviews of September 2014. Which brand of beers obtained the highest star ratings? [/INST]
SELECT DISTINCT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2014-09-01' AND '2014-09-30';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: From which cities are the customers who gave 5 stars in their reviews in November 2012? [/INST]
SELECT DISTINCT T1.City FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2012-11-01' AND '2012-11-30';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What brands of beer has Peg Winchester consumed? [/INST]
SELECT T3.BrandName FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T1.First = 'Peg' AND T1.Last = 'Winchester';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What brand of beer has been the worst rated most times? [/INST]
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T2.BrandID = T1.BrandID WHERE T2.StarRating = 1 GROUP BY T1.BrandName ORDER BY COUNT(T1.BrandName) DESC LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the name of all the customers who have ever given a 5-star review? [/INST]
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5;
[INST] Here is a database schema: geolocation : LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID Latitude [ REAL ] Longitude [ REAL ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: At what latitude is the Thomas Kemper brand beer consumed the most? [/INST]
SELECT T3.Latitude FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN geolocation AS T3 ON T1.LocationID = T3.LocationID WHERE T2.BrandName = 'Thomas Kemper' GROUP BY T3.Latitude ORDER BY COUNT(T1.BrandID) DESC LIMIT 1;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What star rating is the most common for beers containing corn syrup? [/INST]
SELECT T2.StarRating FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.CornSyrup = 'TRUE' GROUP BY T2.StarRating ORDER BY COUNT(T2.StarRating) DESC LIMIT 1;
[INST] Here is a database schema: geolocation : LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID Latitude [ REAL ] Longitude [ REAL ] location : LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID LocationName [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Please write me a SQL statement that answers the following question: What is the precise location of zip code 95819? [/INST]
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.ZipCode = 95819;
[INST] Here is a database schema: geolocation : LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID Latitude [ REAL ] Longitude [ REAL ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: What brands of beers are manufactured at coordinates 38,566,129, -121,426,432? [/INST]
SELECT DISTINCT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID INNER JOIN geolocation AS T3 ON T1.LocationID = T3.LocationID WHERE T3.Latitude = '38.566129' AND T3.Longitude = '-121.426432';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: What is the average unit profit for wholesalers of canned beers? [/INST]
SELECT AVG(T2.CurrentRetailPrice - T2.WholesaleCost) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.ContainerType = 'Can';
[INST] Here is a database schema: rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: List the brand IDs of the beers whose star rating is more than 3. [/INST]
SELECT BrandID FROM rootbeerreview WHERE StarRating > 3;
[INST] Here is a database schema: rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: How many brands of bottle root beer were purchased between 4/3/2015 and 10/26/2015? [/INST]
SELECT COUNT(BrandID) FROM rootbeer WHERE ContainerType = 'Bottle' AND PurchaseDate BETWEEN '2015-04-03' AND '2015-10-26';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the full name of the customer who gave a 5-star rating and commented "The quintessential dessert root beer. No ice cream required" on his review? [/INST]
SELECT T1.First, T1.Last FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 5 AND T2.Review = 'The quintessential dessert root beer. No ice cream required.';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Tally the email addresses and phone numbers of customers from Sacramento who gave a star rating of more than 3 in 2014. [/INST]
SELECT DISTINCT T1.Email, T1.PhoneNumber FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating > 3 AND T1.City = 'Sacramento' AND T2.ReviewDate BETWEEN '2014-01-01' AND '2014-12-31';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: How many female mailing list subscribers from Sacramento gave a 4-star rating between 1/3/2016 and 10/26/2016? [/INST]
SELECT COUNT(T1.CustomerID) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.StarRating = 4 AND T1.City = 'Sacramento' AND T1.Gender = 'F' AND T1.SubscribedToEmailList = 'TRUE' AND T2.ReviewDate BETWEEN '2013-01-03' AND '2013-10-26';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Give me the brewery and brand names of canned root beer that were purchased before 6/6/2015. [/INST]
SELECT DISTINCT T2.BreweryName, T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T1.PurchaseDate < '2015-06-06' AND T1.ContainerType = 'Can';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: List the brand names of bottled root beer whose first brewing year is no later than 1930. [/INST]
SELECT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.FirstBrewedYear < '1930-01-01' AND T1.ContainerType = 'Bottle' ORDER BY T2.FirstBrewedYear LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the average star rating given by female customers to brand ID 10018 from 1/25/2015 to 3/10/2015? [/INST]
SELECT AVG(T2.StarRating) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.BrandID = 10018 AND T1.Gender = 'F' AND T2.ReviewDate BETWEEN '2013-01-25' AND '2015-03-10';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the brand name of the root beer that gained a 1-star rating from customer ID 331115 while saying, "Yuk, more like licorice soda"? [/INST]
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.CustomerID = 331115 AND T2.Review = 'Yuk, more like licorice soda.' AND T2.StarRating = 1;
[INST] Here is a database schema: geolocation : LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID Latitude [ REAL ] Longitude [ REAL ] location : LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID LocationName [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Please write me a SQL statement that answers the following question: What is the precise coordinate of Sac State Union? [/INST]
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State Union';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What did the customer say in his or her review of Bulldog root beer on 7/26/2013? [/INST]
SELECT T2.Review FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.BrandName = 'Bulldog' AND T2.ReviewDate = '2013-07-26';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: List down the brand names of root beer that gained a 5-star rating from a customer's review in 2013. Calculate the unit profit available to wholesalers for each brand. [/INST]
SELECT T1.BrandName, T1.CurrentRetailPrice - T1.WholesaleCost AS result FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 AND T2.ReviewDate BETWEEN '2013-01-01' AND '2013-12-31';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Give me the full name of the first customer, and tell me how long ago he or she wrote his or her first review since making his or her first purchase. [/INST]
SELECT T1.First, T1.Last , strftime('%J', ReviewDate) - strftime('%J', FirstPurchaseDate) AS TIMEAGO FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID LIMIT 1;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: List out the root beer ID for the brand Bulldog, Bundaberg, Dad's, Dog n Suds and Virgil's. [/INST]
SELECT T1.RootBeerID FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T2.BrandID = T1.BrandID WHERE T2.BrandName IN ('Bulldog', 'Bundaberg', 'Dad''s', 'Dog n Suds', 'Virgil''s');
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: What is the average review given by a subscriber? [/INST]
SELECT AVG(T2.StarRating) FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.SubscribedToEmailList = 'TRUE';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: What is the amount difference between the bottles of root beer sold from Louisiana and Missouri? [/INST]
SELECT ( SELECT COUNT(T1.BrandID) FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID WHERE T2.State = 'LA' AND T1.ContainerType = 'Bottle' ) - ( SELECT COUNT(T3.BrandID) FROM rootbeer AS T3 INNER JOIN rootbeerbrand AS T4 ON T3.BrandID = T4.BrandID WHERE T4.State = 'MO' AND T3.ContainerType = 'Bottle' ) AS DIFFERENCE;
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeer : RootBeerID [ INTEGER ] primary_key BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID ContainerType [ TEXT ] LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID PurchaseDate [ DATE ] Please write me a SQL statement that answers the following question: Which of the root beer brand have the lowest purchase? [/INST]
SELECT T2.BrandName FROM rootbeer AS T1 INNER JOIN rootbeerbrand AS T2 ON T1.BrandID = T2.BrandID GROUP BY T2.BrandID ORDER BY COUNT(T1.BrandID) LIMIT 1;
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] Please write me a SQL statement that answers the following question: Please name all of the cities in California. [/INST]
SELECT DISTINCT City FROM customers WHERE State = 'CA';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] Please write me a SQL statement that answers the following question: What is the percentage of female customers who subscribed to the email list? [/INST]
SELECT CAST(COUNT(CASE WHEN Gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(SubscribedToEmailList) FROM customers WHERE SubscribedToEmailList = 'TRUE';
[INST] Here is a database schema: customers : CustomerID [ INTEGER ] primary_key First [ TEXT ] Last [ TEXT ] StreetAddress [ TEXT ] City [ TEXT ] State [ TEXT ] ZipCode [ INTEGER ] Email [ TEXT ] PhoneNumber [ TEXT ] FirstPurchaseDate [ DATE ] SubscribedToEmailList [ TEXT ] Gender [ TEXT ] rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: How many stars did Urijah Faber rate for Frostie? [/INST]
SELECT T2.StarRating FROM customers AS T1 INNER JOIN rootbeerreview AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN rootbeerbrand AS T3 ON T2.BrandID = T3.BrandID WHERE T1.First = 'Urijah' AND T1.Last = 'Faber' AND T3.BrandName = 'Frostie';
[INST] Here is a database schema: rootbeerbrand : BrandID [ INTEGER ] primary_key BrandName [ TEXT ] FirstBrewedYear [ INTEGER ] BreweryName [ TEXT ] City [ TEXT ] State [ TEXT ] Country [ TEXT ] Description [ TEXT ] CaneSugar [ TEXT ] CornSyrup [ TEXT ] Honey [ TEXT ] ArtificialSweetener [ TEXT ] Caffeinated [ TEXT ] Alcoholic [ TEXT ] AvailableInCans [ TEXT ] AvailableInBottles [ TEXT ] AvailableInKegs [ TEXT ] Website [ TEXT ] FacebookPage [ TEXT ] Twitter [ TEXT ] WholesaleCost [ REAL ] CurrentRetailPrice [ REAL ] rootbeerreview : CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID StarRating [ INTEGER ] ReviewDate [ DATE ] Review [ TEXT ] Please write me a SQL statement that answers the following question: Which brand has the lowest star rating with a "Too spicy!" review? [/INST]
SELECT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T2.BrandID = T1.BrandID WHERE T2.StarRating = 1 AND T2.Review = 'Too Spicy!';