Search is not available for this dataset
db_id
stringlengths
3
31
query
stringlengths
20
523
question
stringlengths
3
224
schema
stringlengths
589
322M
query_res
stringlengths
0
363k
department_management
SELECT count(*) FROM head WHERE age > 56
How many heads of the departments are older than 56 ?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(5,)
department_management
SELECT name , born_state , age FROM head ORDER BY age
List the name, born state and age of the heads of departments ordered by age.
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('Pádraig Harrington', 'Connecticut', 43.0) ('Stewart Cink', 'Florida', 50.0) ('Dudley Hart', 'California', 52.0) ('Jeff Maggert', 'Delaware', 53.0) ('Nick Faldo', 'California', 56.0) ('Tiger Woods', 'Alabama', 67.0) ('Franklin Langham', 'Connecticut', 67.0) ('Sergio García', 'California', 68.0) ('K. J. Choi', 'Alabama', 69.0) ('Billy Mayfair', 'California', 69.0)
department_management
SELECT creation , name , budget_in_billions FROM department
List the creation year, name and budget of each department.
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('1789', 'State', 9.96) ('1789', 'Treasury', 11.1) ('1947', 'Defense', 439.3) ('1870', 'Justice', 23.4) ('1849', 'Interior', 10.7) ('1889', 'Agriculture', 77.6) ('1903', 'Commerce', 6.2) ('1913', 'Labor', 59.7) ('1953', 'Health and Human Services', 543.2) ('1965', 'Housing and Urban Development', 46.2) ('1966', 'Transportation', 58.0) ('1977', 'Energy', 21.5) ('1979', 'Education', 62.8) ('1989', 'Veterans Affairs', 73.2) ('2002', 'Homeland Security', 44.6)
department_management
SELECT max(budget_in_billions) , min(budget_in_billions) FROM department
What are the maximum and minimum budget of the departments?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(543.2, 6.2)
department_management
SELECT avg(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15
What is the average number of employees of the departments whose rank is between 10 and 15?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(105468.16666666667,)
department_management
SELECT name FROM head WHERE born_state != 'California'
What are the names of the heads who are born outside the California state?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('Tiger Woods',) ('K. J. Choi',) ('Jeff Maggert',) ('Stewart Cink',) ('Pádraig Harrington',) ('Franklin Langham',)
department_management
SELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T3.born_state = 'Alabama'
What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('1903',)
department_management
SELECT born_state FROM head GROUP BY born_state HAVING count(*) >= 3
What are the names of the states where at least 3 heads were born?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('California',)
department_management
SELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1
In which year were most departments established?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('1789',)
department_management
SELECT T1.name , T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id WHERE T2.temporary_acting = 'Yes'
Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('Treasury', 115897.0) ('Homeland Security', 208000.0) ('Treasury', 115897.0)
department_management
SELECT count(DISTINCT temporary_acting) FROM management
How many acting statuses are there?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(2,)
department_management
SELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management);
How many departments are led by heads who are not mentioned?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(11,)
department_management
SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id = T2.head_id WHERE T2.temporary_acting = 'Yes'
What are the distinct ages of the heads who are acting?
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(53.0,) (52.0,) (69.0,)
department_management
SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Homeland Security'
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
('California',)
department_management
SELECT T1.department_id , T1.name , count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id = T2.department_id GROUP BY T1.department_id HAVING count(*) > 1
Which department has more than 1 head at a time? List the id, name and the number of heads.
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(2, 'Treasury', 2)
department_management
SELECT head_id , name FROM head WHERE name LIKE '%Ha%'
Which head's name has the substring 'Ha'? List the id and name.
PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "department" ( "Department_ID" int, "Name" text, "Creation" text, "Ranking" int, "Budget_in_Billions" real, "Num_Employees" real, PRIMARY KEY ("Department_ID") ); INSERT INTO department VALUES(1,'State','1789','1',9.9600000000000008526,30265.999999999999999); INSERT INTO department VALUES(2,'Treasury','1789','2',11.099999999999999644,115896.99999999999999); INSERT INTO department VALUES(3,'Defense','1947','3',439.30000000000001135,3000000.0); INSERT INTO department VALUES(4,'Justice','1870','4',23.399999999999998578,112556.99999999999999); INSERT INTO department VALUES(5,'Interior','1849','5',10.699999999999999289,71436.000000000000002); INSERT INTO department VALUES(6,'Agriculture','1889','6',77.599999999999994316,109831.99999999999999); INSERT INTO department VALUES(7,'Commerce','1903','7',6.2000000000000001776,35999.999999999999999); INSERT INTO department VALUES(8,'Labor','1913','8',59.700000000000002843,17346.999999999999999); INSERT INTO department VALUES(9,'Health and Human Services','1953','9',543.20000000000004548,66999.999999999999998); INSERT INTO department VALUES(10,'Housing and Urban Development','1965','10',46.200000000000002843,10599.999999999999999); INSERT INTO department VALUES(11,'Transportation','1966','11',58.000000000000000001,58621.999999999999998); INSERT INTO department VALUES(12,'Energy','1977','12',21.5,116099.99999999999999); INSERT INTO department VALUES(13,'Education','1979','13',62.799999999999997156,4487.0000000000000001); INSERT INTO department VALUES(14,'Veterans Affairs','1989','14',73.200000000000002842,234999.99999999999999); INSERT INTO department VALUES(15,'Homeland Security','2002','15',44.600000000000001422,207999.99999999999999); CREATE TABLE IF NOT EXISTS "head" ( "head_ID" int, "name" text, "born_state" text, "age" real, PRIMARY KEY ("head_ID") ); INSERT INTO head VALUES(1,'Tiger Woods','Alabama',66.999999999999999998); INSERT INTO head VALUES(2,'Sergio García','California',68.000000000000000001); INSERT INTO head VALUES(3,'K. J. Choi','Alabama',69.0); INSERT INTO head VALUES(4,'Dudley Hart','California',51.999999999999999998); INSERT INTO head VALUES(5,'Jeff Maggert','Delaware',53.000000000000000001); INSERT INTO head VALUES(6,'Billy Mayfair','California',69.0); INSERT INTO head VALUES(7,'Stewart Cink','Florida',50.0); INSERT INTO head VALUES(8,'Nick Faldo','California',55.999999999999999999); INSERT INTO head VALUES(9,'Pádraig Harrington','Connecticut',43.000000000000000001); INSERT INTO head VALUES(10,'Franklin Langham','Connecticut',66.999999999999999998); CREATE TABLE IF NOT EXISTS "management" ( "department_ID" int, "head_ID" int, "temporary_acting" text, PRIMARY KEY ("Department_ID","head_ID"), FOREIGN KEY ("Department_ID") REFERENCES `department`("Department_ID"), FOREIGN KEY ("head_ID") REFERENCES `head`("head_ID") ); INSERT INTO management VALUES(2,5,'Yes'); INSERT INTO management VALUES(15,4,'Yes'); INSERT INTO management VALUES(2,6,'Yes'); INSERT INTO management VALUES(7,3,'No'); INSERT INTO management VALUES(11,10,'No'); COMMIT;
(4, 'Dudley Hart') (9, 'Pádraig Harrington') (10, 'Franklin Langham')
farm
SELECT count(*) FROM farm
How many farms are there?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(8,)
farm
SELECT count(*) FROM farm
Count the number of farms.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(8,)
farm
SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC
List the total number of horses on farms in ascending order.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(2546.9,) (2604.8,) (3658.9,) (4781.3,) (5056.5,) (5308.2,) (5486.9,) (5607.5,)
farm
SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC
What is the total horses record for each farm, sorted ascending?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(2546.9,) (2604.8,) (3658.9,) (4781.3,) (5056.5,) (5308.2,) (5486.9,) (5607.5,)
farm
SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens'
What are the hosts of competitions whose theme is not "Aliens"?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Miley Cyrus Jared Leto and Karen Mok',) ('Leehom Wang and Kelly Rowland',) ('Alicia Keys',) ('Vanness Wu and Michelle Branch',) ('Shaggy and Coco Lee',)
farm
SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens'
Return the hosts of competitions for which the theme is not Aliens?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Miley Cyrus Jared Leto and Karen Mok',) ('Leehom Wang and Kelly Rowland',) ('Alicia Keys',) ('Vanness Wu and Michelle Branch',) ('Shaggy and Coco Lee',)
farm
SELECT Theme FROM farm_competition ORDER BY YEAR ASC
What are the themes of farm competitions sorted by year in ascending order?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Aliens',) ('MTV Cube',) ("Valentine's Day",) ('MTV Asia Aid',) ('Codehunters',) ('Carnival M is back!',)
farm
SELECT Theme FROM farm_competition ORDER BY YEAR ASC
Return the themes of farm competitions, sorted by year ascending.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Aliens',) ('MTV Cube',) ("Valentine's Day",) ('MTV Asia Aid',) ('Codehunters',) ('Carnival M is back!',)
farm
SELECT avg(Working_Horses) FROM farm WHERE Total_Horses > 5000
What is the average number of working horses of farms with more than 5000 total number of horses?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(3977.7500000000005,)
farm
SELECT avg(Working_Horses) FROM farm WHERE Total_Horses > 5000
Give the average number of working horses on farms with more than 5000 total horses.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(3977.7500000000005,)
farm
SELECT max(Cows) , min(Cows) FROM farm
What are the maximum and minimum number of cows across all farms.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(3987.0, 2407.2)
farm
SELECT max(Cows) , min(Cows) FROM farm
Return the maximum and minimum number of cows across all farms.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(3987.0, 2407.2)
farm
SELECT count(DISTINCT Status) FROM city
How many different statuses do cities have?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(2,)
farm
SELECT count(DISTINCT Status) FROM city
Count the number of different statuses.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(2,)
farm
SELECT Official_Name FROM city ORDER BY Population DESC
List official names of cities in descending order of population.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Grand Falls/Grand-Sault',) ('Perth-Andover',) ('Plaster Rock',) ('Drummond',) ('Aroostook',)
farm
SELECT Official_Name FROM city ORDER BY Population DESC
What are the official names of cities, ordered descending by population?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Grand Falls/Grand-Sault',) ('Perth-Andover',) ('Plaster Rock',) ('Drummond',) ('Aroostook',)
farm
SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1
List the official name and status of the city with the largest population.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Grand Falls/Grand-Sault', 'Town')
farm
SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1
What is the official name and status of the city with the most residents?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Grand Falls/Grand-Sault', 'Town')
farm
SELECT T2.Year , T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID
Show the years and the official names of the host cities of competitions.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(2013, 'Grand Falls/Grand-Sault') (2006, 'Perth-Andover') (2005, 'Plaster Rock') (2004, 'Drummond') (2003, 'Aroostook') (2002, 'Aroostook')
farm
SELECT T2.Year , T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID
Give the years and official names of the cities of each competition.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
(2013, 'Grand Falls/Grand-Sault') (2006, 'Perth-Andover') (2005, 'Plaster Rock') (2004, 'Drummond') (2003, 'Aroostook') (2002, 'Aroostook')
farm
SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1
Show the official names of the cities that have hosted more than one competition.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Aroostook',)
farm
SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1
What are the official names of cities that have hosted more than one competition?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Aroostook',)
farm
SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1
Show the status of the city that has hosted the greatest number of competitions.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Village',)
farm
SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1
What is the status of the city that has hosted the most competitions?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Village',)
farm
SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000
Please show the themes of competitions with host cities having populations larger than 1000.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Carnival M is back!',) ('Codehunters',) ('MTV Asia Aid',)
farm
SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000
What are the themes of competitions that have corresponding host cities with more than 1000 residents?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Carnival M is back!',) ('Codehunters',) ('MTV Asia Aid',)
farm
SELECT Status , avg(Population) FROM city GROUP BY Status
Please show the different statuses of cities and the average population of cities with each status.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Town', 5706.0) ('Village', 1009.75)
farm
SELECT Status , avg(Population) FROM city GROUP BY Status
What are the statuses and average populations of each city?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Town', 5706.0) ('Village', 1009.75)
farm
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC
Please show the different statuses, ordered by the number of cities that have each.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Town',) ('Village',)
farm
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC
Return the different statuses of cities, ascending by frequency.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Town',) ('Village',)
farm
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
List the most common type of Status across cities.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Village',)
farm
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
What is the most common status across all cities?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
('Village',)
farm
SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition)
List the official names of cities that have not held any competition.
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);
farm
SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition)
What are the official names of cities that have not hosted a farm competition?
PRAGMA foreign_keys = ON; CREATE TABLE "city" ( "City_ID" int, "Official_Name" text, "Status" text, "Area_km_2" real, "Population" real, "Census_Ranking" text, PRIMARY KEY ("City_ID") ); CREATE TABLE "farm" ( "Farm_ID" int, "Year" int, "Total_Horses" real, "Working_Horses" real, "Total_Cattle" real, "Oxen" real, "Bulls" real, "Cows" real, "Pigs" real, "Sheep_and_Goats" real, PRIMARY KEY ("Farm_ID") ); CREATE TABLE "farm_competition" ( "Competition_ID" int, "Year" int, "Theme" text, "Host_city_ID" int, "Hosts" text, PRIMARY KEY ("Competition_ID"), FOREIGN KEY (`Host_city_ID`) REFERENCES `city`(`City_ID`) ); CREATE TABLE "competition_record" ( "Competition_ID" int, "Farm_ID" int, "Rank" int, PRIMARY KEY ("Competition_ID","Farm_ID"), FOREIGN KEY (`Competition_ID`) REFERENCES `farm_competition`(`Competition_ID`), FOREIGN KEY (`Farm_ID`) REFERENCES `farm`(`Farm_ID`) ); INSERT INTO "city" VALUES (1,"Grand Falls/Grand-Sault","Town","18.06","5706","636 of 5008"); INSERT INTO "city" VALUES (2,"Perth-Andover","Village","8.89","1778","1442 of 5,008"); INSERT INTO "city" VALUES (3,"Plaster Rock","Village","3.09","1135","1936 of 5,008"); INSERT INTO "city" VALUES (4,"Drummond","Village","8.91","775","2418 of 5008"); INSERT INTO "city" VALUES (5,"Aroostook","Village","2.24","351","3460 of 5008"); INSERT INTO "farm" VALUES (1,"1927","5056.5","3900.1","8374.5","805.5","31.6","3852.1","4412.4","7956.3"); INSERT INTO "farm" VALUES (2,"1928","5486.9","4090.5","8604.8","895.3","32.8","3987.0","6962.9","8112.2"); INSERT INTO "farm" VALUES (3,"1929","5607.5","4198.8","7611.0","593.7","26.9","3873.0","4161.2","7030.8"); INSERT INTO "farm" VALUES (4,"1930","5308.2","3721.6","6274.1","254.8","49.6","3471.6","3171.8","4533.4"); INSERT INTO "farm" VALUES (5,"1931","4781.3","3593.7","6189.5","113.8","40.0","3377.0","3373.3","3364.8"); INSERT INTO "farm" VALUES (6,"1932","3658.9","3711.6","5006.7","105.2","71.6","2739.5","2623.7","2109.5"); INSERT INTO "farm" VALUES (7,"1933","2604.8","3711.2","4446.3","116.9","37.6","2407.2","2089.2","2004.7"); INSERT INTO "farm" VALUES (8,"1934","2546.9","2197.3","5277.5","156.5","46.7","2518.0","4236.7","2197.1"); INSERT INTO "farm_competition" VALUES (1,"2013","Carnival M is back!",1,"Miley Cyrus Jared Leto and Karen Mok"); INSERT INTO "farm_competition" VALUES (2,"2006","Codehunters",2,"Leehom Wang and Kelly Rowland"); INSERT INTO "farm_competition" VALUES (3,"2005","MTV Asia Aid",3,"Alicia Keys"); INSERT INTO "farm_competition" VALUES (4,"2004","Valentine's Day",4,"Vanness Wu and Michelle Branch"); INSERT INTO "farm_competition" VALUES (5,"2003","MTV Cube",5,"Shaggy and Coco Lee"); INSERT INTO "farm_competition" VALUES (6,"2002","Aliens",5,"Mandy Moore and Ronan Keating"); INSERT INTO "competition_record" VALUES (1,8,1); INSERT INTO "competition_record" VALUES (1,2,2); INSERT INTO "competition_record" VALUES (1,3,3); INSERT INTO "competition_record" VALUES (2,1,3); INSERT INTO "competition_record" VALUES (2,4,1); INSERT INTO "competition_record" VALUES (2,3,2); INSERT INTO "competition_record" VALUES (3,7,1); INSERT INTO "competition_record" VALUES (3,1,3); INSERT INTO "competition_record" VALUES (4,3,2); INSERT INTO "competition_record" VALUES (4,1,4); INSERT INTO "competition_record" VALUES (5,5,1); INSERT INTO "competition_record" VALUES (5,3,2);

Dataset Card for "spider"

More Information needed

Downloads last month
98
Edit dataset card