db_id
stringclasses
127 values
query
stringlengths
20
523
question
stringlengths
16
224
schema
stringclasses
127 values
county_public_safety
SELECT Name FROM city ORDER BY White DESC LIMIT 5
List the names of the city with the top 5 white percentages.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Name FROM city ORDER BY White DESC LIMIT 5
What are the names of the five cities with the greatest proportion of white people?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
Show names of cities and names of counties they are in.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT T1.Name , T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
What are the names of cities, as well as the names of the counties they correspond to?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT T1.White , T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
Show white percentages of cities and the crime rates of counties they are in.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT T1.White , T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID
What are the white percentages of cities, and the corresponding crime rates of the counties they correspond to?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1)
Show the name of cities in the county that has the largest number of police officers.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1)
What are the names of cities that are in the county with the most police officers?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000)
Show the number of cities in counties that have a population more than 20000.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT count(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000)
How many cities are in counties that have populations of over 20000?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID WHERE T1.White > 90
Show the crime rate of counties with a city having white percentage more than 90.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID WHERE T1.White > 90
What are the crime rates of counties that contain cities that have white percentages of over 90?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force
Please show the police forces and the number of counties with each police force.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force
How many counties correspond to each police force?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
What is the location shared by most counties?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
Which location has the most corresponding counties?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city)
List the names of counties that do not have any cities.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Name FROM county_public_safety WHERE County_ID NOT IN (SELECT County_ID FROM city)
What are the names of counties that do not contain any cities?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West"
Show the police force shared by counties with location on the east and west.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West"
Which police forces operate in both counties that are located in the East and in the West?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100)
Show the names of cities in counties that have a crime rate less than 100.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100)
What are the names of cities that are in counties that have a crime rate below 100?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Case_burden FROM county_public_safety ORDER BY Population DESC
Show the case burden of counties in descending order of population.
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
county_public_safety
SELECT Case_burden FROM county_public_safety ORDER BY Population DESC
What are the case burdens of counties, ordered descending by population?
PRAGMA foreign_keys = ON; CREATE TABLE "county_public_safety" ( "County_ID" int, "Name" text, "Population" int, "Police_officers" int, "Residents_per_officer" int, "Case_burden" int, "Crime_rate" real, "Police_force" text, "Location" text, PRIMARY KEY ("County_ID") ); CREATE TABLE "city" ( "City_ID" int, "County_ID" int, "Name" text, "White" real, "Black" real, "Amerindian" real, "Asian" real, "Multiracial" real, "Hispanic" real, PRIMARY KEY ("City_ID"), FOREIGN KEY ("County_ID") REFERENCES "county_public_safety"("County_ID") ); INSERT INTO "county_public_safety" VALUES (1,"Abbotsford","128165","187","685","81","118","Abbotsford Police Department","East"); INSERT INTO "city" VALUES (1,1,"Adjuntas","93.1","3.1","0.3","0.0","3.4","99.6");
local_govt_mdm
SELECT T1.cmi_details FROM Customer_Master_Index AS T1 JOIN CMI_Cross_References AS T2 ON T1.master_customer_id = T2.master_customer_id WHERE T2.source_system_code = 'Tax'
what are the details of the cmi masters that have the cross reference code 'Tax'?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT T1.cmi_cross_ref_id , T1.source_system_code FROM CMI_Cross_References AS T1 JOIN Council_Tax AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id GROUP BY T1.cmi_cross_ref_id HAVING count(*) >= 1
What is the cmi cross reference id that is related to at least one council tax entry? List the cross reference id and source system code.
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT T2.cmi_cross_ref_id , T2.master_customer_id , count(*) FROM Business_Rates AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id GROUP BY T2.cmi_cross_ref_id
How many business rates are related to each cmi cross reference? List cross reference id, master customer id and the n
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT T1.source_system_code , T2.council_tax_id FROM CMI_Cross_References AS T1 JOIN Benefits_Overpayments AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id ORDER BY T2.council_tax_id
What is the tax source system code related to the benefits and overpayments? List the code and the benifit id, order by benifit id.
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT T1.source_system_code , T1.master_customer_id , T2.council_tax_id FROM CMI_Cross_References AS T1 JOIN Parking_Fines AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id
Wat is the tax source system code and master customer id of the taxes related to each parking fine id?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT T1.council_tax_id FROM Rent_Arrears AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id JOIN Customer_Master_Index AS T3 ON T3.master_customer_id = T2.master_customer_id WHERE T3.cmi_details != 'Schmidt , Kertzmann and Lubowitz'
What are the renting arrears tax ids related to the customer master index whose detail is not 'Schmidt, Kertzmann and Lubowitz'?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT T1.electoral_register_id FROM Electoral_Register AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id WHERE T2.source_system_code = 'Electoral' OR T2.source_system_code = 'Tax'
What are the register ids of electoral registries that have the cross reference source system code 'Electoral' or 'Tax'?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT count(DISTINCT source_system_code) FROM CMI_cross_references
How many different source system code for the cmi cross references are there?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT * FROM customer_master_index ORDER BY cmi_details DESC
List all information about customer master index, and sort them by details in descending order.
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT council_tax_id , cmi_cross_ref_id FROM parking_fines
List the council tax ids and their related cmi cross references of all the parking fines.
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT count(*) FROM rent_arrears
How many council taxes are collected for renting arrears ?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT DISTINCT T2.source_system_code FROM customer_master_index AS T1 JOIN cmi_cross_references AS T2 ON T1.master_customer_id = T2.master_customer_id WHERE T1.cmi_details = 'Gottlieb , Becker and Wyman'
What are the distinct cross reference source system codes which are related to the master customer details 'Gottlieb, Becker and Wyman'?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT cmi_cross_ref_id FROM cmi_cross_references EXCEPT SELECT cmi_cross_ref_id FROM parking_fines
Which cmi cross reference id is not related to any parking taxes?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
local_govt_mdm
SELECT DISTINCT source_system_code FROM cmi_cross_references WHERE source_system_code LIKE '%en%'
Which distinct source system code includes the substring 'en'?
PRAGMA foreign_keys = ON; CREATE TABLE Customer_Master_Index ( master_customer_id INTEGER NOT NULL, cmi_details VARCHAR(255), PRIMARY KEY (master_customer_id) ); CREATE TABLE CMI_Cross_References ( cmi_cross_ref_id INTEGER NOT NULL, master_customer_id INTEGER NOT NULL, source_system_code CHAR(15) NOT NULL, PRIMARY KEY (cmi_cross_ref_id), FOREIGN KEY (master_customer_id) REFERENCES Customer_Master_Index (master_customer_id) ); CREATE TABLE Council_Tax ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Business_Rates ( business_rates_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (business_rates_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Benefits_Overpayments ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Parking_Fines ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Rent_Arrears ( council_tax_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (council_tax_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); CREATE TABLE Electoral_Register ( electoral_register_id INTEGER NOT NULL, cmi_cross_ref_id INTEGER NOT NULL, PRIMARY KEY (electoral_register_id), FOREIGN KEY (cmi_cross_ref_id) REFERENCES CMI_Cross_References (cmi_cross_ref_id) ); INSERT INTO `Customer_Master_Index` (`master_customer_id`, `cmi_details`) VALUES (1, 'Schmitt-Lang')INSERT INTO `CMI_Cross_References` (`cmi_cross_ref_id`, `master_customer_id`, `source_system_code`) VALUES (2, 4, 'Rent')INSERT INTO `Benefits_Overpayments` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Business_Rates` (`business_rates_id`, `cmi_cross_ref_id`) VALUES (5, 49)INSERT INTO `Council_Tax` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (1, 101)INSERT INTO `Electoral_Register` (`electoral_register_id`, `cmi_cross_ref_id`) VALUES (3, 65)INSERT INTO `Parking_Fines` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (9, 4)INSERT INTO `Rent_Arrears` (`council_tax_id`, `cmi_cross_ref_id`) VALUES (7, 2)
party_host
SELECT count(*) FROM party
How many parties are there?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT count(*) FROM party
Count the number of parties.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Party_Theme FROM party ORDER BY Number_of_hosts ASC
List the themes of parties in ascending order of number of hosts.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Party_Theme FROM party ORDER BY Number_of_hosts ASC
What are the themes of parties ordered by the number of hosts in ascending manner?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Party_Theme , LOCATION FROM party
What are the themes and locations of parties?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Party_Theme , LOCATION FROM party
Give me the theme and location of each party.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT First_year , Last_year FROM party WHERE Party_Theme = "Spring" OR Party_Theme = "Teqnology"
Show the first year and last year of parties with theme "Spring" or "Teqnology".
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT First_year , Last_year FROM party WHERE Party_Theme = "Spring" OR Party_Theme = "Teqnology"
What are the first year and last year of the parties whose theme is "Spring" or "Teqnology"?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT avg(Number_of_hosts) FROM party
What is the average number of hosts for parties?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT avg(Number_of_hosts) FROM party
Compute the average number of hosts for parties.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT LOCATION FROM party ORDER BY Number_of_hosts DESC LIMIT 1
What is the location of the party with the most hosts?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT LOCATION FROM party ORDER BY Number_of_hosts DESC LIMIT 1
Which party had the most hosts? Give me the party location.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Nationality , COUNT(*) FROM HOST GROUP BY Nationality
Show different nationalities along with the number of hosts of each nationality.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Nationality , COUNT(*) FROM HOST GROUP BY Nationality
How many hosts does each nationality have? List the nationality and the count.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Nationality FROM HOST GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
Show the most common nationality of hosts.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Nationality FROM HOST GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
Which nationality has the most hosts?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Nationality FROM HOST WHERE Age > 45 INTERSECT SELECT Nationality FROM HOST WHERE Age < 35
Show the nations that have both hosts older than 45 and hosts younger than 35.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Nationality FROM HOST WHERE Age > 45 INTERSECT SELECT Nationality FROM HOST WHERE Age < 35
Which nations have both hosts of age above 45 and hosts of age below 35?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T3.Party_Theme , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID
Show the themes of parties and the names of the party hosts.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T3.Party_Theme , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID
For each party, return its theme and the name of its host.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T3.Location , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID ORDER BY T2.Age
Show the locations of parties and the names of the party hosts in ascending order of the age of the host.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T3.Location , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID ORDER BY T2.Age
For each party, find its location and the name of its host. Sort the result in ascending order of the age of the host.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T3.Location FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T2.Age > 50
Show the locations of parties with hosts older than 50.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T3.Location FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T2.Age > 50
Which parties have hosts of age above 50? Give me the party locations.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T3.Number_of_hosts > 20
Show the host names for parties with number of hosts greater than 20.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T3.Number_of_hosts > 20
Which parties have more than 20 hosts? Give me the host names for these parties.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Name , Nationality FROM HOST ORDER BY Age DESC LIMIT 1
Show the name and the nationality of the oldest host.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Name , Nationality FROM HOST ORDER BY Age DESC LIMIT 1
What are the name and the nationality of the host of the highest age?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Name FROM HOST WHERE Host_ID NOT IN (SELECT Host_ID FROM party_host)
List the names of hosts who did not serve as a host of any party in our record.
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
party_host
SELECT Name FROM HOST WHERE Host_ID NOT IN (SELECT Host_ID FROM party_host)
What are the names of hosts who did not host any party in our record?
PRAGMA foreign_keys = ON; CREATE TABLE "party" ( "Party_ID" int, "Party_Theme" text, "Location" text, "First_year" text, "Last_year" text, "Number_of_hosts" int, PRIMARY KEY ("Party_ID") ); CREATE TABLE "host" ( "Host_ID" int, "Name" text, "Nationality" text, "Age" text, PRIMARY KEY ("Host_ID") ); CREATE TABLE "party_host" ( "Party_ID" int, "Host_ID" int, "Is_Main_in_Charge" bool, PRIMARY KEY ("Party_ID","Host_ID"), FOREIGN KEY ("Host_ID") REFERENCES `host`("Host_ID"), FOREIGN KEY ("Party_ID") REFERENCES `party`("Party_ID") ); INSERT INTO "party" VALUES (1,"Spring","Hemkade 48 Zaandam","2000","2001","5"); INSERT INTO "host" VALUES (1,"Austin Daye","United States",43); INSERT INTO "party_host" VALUES (1,1,"T");
storm_record
SELECT count(*) FROM region
How many regions do we have?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT count(*) FROM region
Count the number of regions.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_code , region_name FROM region ORDER BY region_code
Show all region code and region name sorted by the codes.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_code , region_name FROM region ORDER BY region_code
What are the codes and names for all regions, sorted by codes?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_name FROM region ORDER BY region_name
List all region names in alphabetical order.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_name FROM region ORDER BY region_name
What are the names of the regions in alphabetical order?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_name FROM region WHERE region_name != 'Denmark'
Show names for all regions except for Denmark.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_name FROM region WHERE region_name != 'Denmark'
Return the names of all regions other than Denmark.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT count(*) FROM storm WHERE Number_Deaths > 0
How many storms had death records?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT count(*) FROM storm WHERE Number_Deaths > 0
Count the number of storms in which at least 1 person died.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT name , dates_active , number_deaths FROM storm WHERE number_deaths >= 1
List name, dates active, and number of deaths for all storms with at least 1 death.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT name , dates_active , number_deaths FROM storm WHERE number_deaths >= 1
What are the names, dates active, and number of deaths for storms that had 1 or more death?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT avg(damage_millions_USD) , max(damage_millions_USD) FROM storm WHERE max_speed > 1000
Show the average and maximum damage for all storms with max speed higher than 1000.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT avg(damage_millions_USD) , max(damage_millions_USD) FROM storm WHERE max_speed > 1000
What is the average and maximum damage in millions for storms that had a max speed over 1000?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT sum(number_deaths) , sum(damage_millions_USD) FROM storm WHERE max_speed > (SELECT avg(max_speed) FROM storm)
What is the total number of deaths and damage for all storms with a max speed greater than the average?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT sum(number_deaths) , sum(damage_millions_USD) FROM storm WHERE max_speed > (SELECT avg(max_speed) FROM storm)
Return the total number of deaths and total damange in millions for storms that had a max speed greater than the average.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT name , damage_millions_USD FROM storm ORDER BY max_speed DESC
List name and damage for all storms in a descending order of max speed.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT name , damage_millions_USD FROM storm ORDER BY max_speed DESC
What are the names and damage in millions for storms, ordered by their max speeds descending?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT count(DISTINCT region_id) FROM affected_region
How many regions are affected?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT count(DISTINCT region_id) FROM affected_region
Count the number of different affected regions.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_name FROM region WHERE region_id NOT IN (SELECT region_id FROM affected_region)
Show the name for regions not affected.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT region_name FROM region WHERE region_id NOT IN (SELECT region_id FROM affected_region)
What are the names of regions that were not affected?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.region_name , count(*) FROM region AS T1 JOIN affected_region AS T2 ON T1.region_id = T2.region_id GROUP BY T1.region_id
Show the name for regions and the number of storms for each region.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.region_name , count(*) FROM region AS T1 JOIN affected_region AS T2 ON T1.region_id = T2.region_id GROUP BY T1.region_id
How many storms occured in each region?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.name , count(*) FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id
List the name for storms and the number of affected regions for each storm.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.name , count(*) FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id
How many regions were affected by each storm?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.name , T1.max_speed FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id ORDER BY count(*) DESC LIMIT 1
What is the storm name and max speed which affected the greatest number of regions?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.name , T1.max_speed FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id ORDER BY count(*) DESC LIMIT 1
Return the name and max speed of the storm that affected the most regions.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT name FROM storm WHERE storm_id NOT IN (SELECT storm_id FROM affected_region)
Show the name of storms which don't have affected region in record.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT name FROM storm WHERE storm_id NOT IN (SELECT storm_id FROM affected_region)
What are the names of storms that did not affect any regions?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING count(*) >= 2 INTERSECT SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING sum(T2.number_city_affected) >= 10
Show storm name with at least two regions and 10 cities affected.
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);
storm_record
SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING count(*) >= 2 INTERSECT SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING sum(T2.number_city_affected) >= 10
What are the names of storms that both affected two or more regions and affected a total of 10 or more cities?
PRAGMA foreign_keys = ON; CREATE TABLE "storm" ( "Storm_ID" int, "Name" text, "Dates_active" text, "Max_speed" int, "Damage_millions_USD" real, "Number_Deaths" int, PRIMARY KEY ("Storm_ID") ); CREATE TABLE "region" ( `Region_id` int, `Region_code` text, `Region_name` text, PRIMARY KEY ("Region_id") ); CREATE TABLE `affected_region` ( `Region_id` int, `Storm_ID` int, `Number_city_affected` real, PRIMARY KEY (`Region_id`,`Storm_ID`), FOREIGN KEY (`Region_id`) REFERENCES `region`(`Region_id`), FOREIGN KEY (`Storm_ID`) REFERENCES `storm`(`Storm_ID`) ); INSERT INTO "storm" VALUES (1,"One","May19–May25","995","13",0); INSERT INTO "region" VALUES (1, "AF", "Afghanistan"); INSERT INTO `affected_region` VALUES (1,1,10);