db_id
stringclasses
146 values
question_en
stringlengths
3
224
hardness
stringclasses
4 values
schema_llm
stringclasses
146 values
query_llm
stringlengths
18
631
schema_llm_min
stringclasses
147 values
schema_dict
stringclasses
146 values
tables_and_columns
stringlengths
18
266
schema_reduzido
stringlengths
25
718
schema_reduzido_only_tables
stringlengths
80
2.27k
department_management
How many heads of the departments are older than 56 ?
easy
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT count(*) FROM head WHERE age > 56
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'head': ['head_id', 'age'] }
TABLE head ( head.head_ID (INT), head.age (REAL), ) Possible JOINs:
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Possible JOINs:
department_management
List the name, born state and age of the heads of departments ordered by age.
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT name , born_state , age FROM head ORDER BY age
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'head': ['head_id', 'name', 'born_state', 'age'] }
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Possible JOINs:
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Possible JOINs:
department_management
List the creation year, name and budget of each department.
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT creation , name , budget_in_billions FROM department
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'name', 'creation', 'budget_in_billions'] }
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Budget_in_Billions (REAL), ) Possible JOINs:
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Possible JOINs:
department_management
What are the maximum and minimum budget of the departments?
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT max(budget_in_billions) , min(budget_in_billions) FROM department
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'budget_in_billions'] }
TABLE department ( department.Department_ID (INT), department.Budget_in_Billions (REAL), ) Possible JOINs:
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Possible JOINs:
department_management
What is the average number of employees of the departments whose rank is between 10 and 15?
easy
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT avg(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'ranking', 'num_employees'] }
TABLE department ( department.Department_ID (INT), department.Ranking (INT), department.Num_Employees (REAL), ) Possible JOINs:
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Possible JOINs:
department_management
What are the names of the heads who are born outside the California state?
easy
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT name FROM head WHERE born_state != 'California'
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'head': ['head_id', 'name', 'born_state'] }
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), ) Possible JOINs:
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Possible JOINs:
department_management
What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?
hard
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT DISTINCT department.creation FROM department JOIN management ON department.department_id = management.department_id JOIN head ON management.head_id = head.head_id WHERE head.born_state = 'Alabama'
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'creation'], 'management': ['department_id', 'head_id'], 'head': ['head_id', 'born_state'] }
TABLE department ( department.Department_ID (INT), department.Creation (TEXT), ) TABLE head ( head.head_ID (INT), head.born_state (TEXT), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), )
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
What are the names of the states where at least 3 heads were born?
easy
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT born_state FROM head GROUP BY born_state HAVING count(*) >= 3
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'head': ['head_id', 'born_state'] }
TABLE head ( head.head_ID (INT), head.born_state (TEXT), ) Possible JOINs:
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Possible JOINs:
department_management
In which year were most departments established?
hard
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'creation'] }
TABLE department ( department.Department_ID (INT), department.Creation (TEXT), ) Possible JOINs:
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Possible JOINs:
department_management
Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'?
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT department.name , department.num_employees FROM department JOIN management ON department.department_id = management.department_id WHERE management.temporary_acting = 'Yes'
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'name', 'num_employees'], 'management': ['department_id', 'temporary_acting'] }
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Num_Employees (REAL), ) TABLE management ( management.department_ID (INT), management.temporary_acting (TEXT), )
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
How many acting statuses are there?
easy
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT count(DISTINCT temporary_acting) FROM management
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'management': ['department_id', 'temporary_acting'] }
TABLE management ( management.department_ID (INT), management.temporary_acting (TEXT), )
TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
How many departments are led by heads who are not mentioned?
extra
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management);
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id'], 'management': ['department_id'] }
TABLE department ( department.Department_ID (INT), ) TABLE management ( management.department_ID (INT), )
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
What are the distinct ages of the heads who are acting?
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT DISTINCT head.age FROM management JOIN head ON head.head_id = management.head_id WHERE management.temporary_acting = 'Yes'
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'management': ['department_id', 'head_id', 'temporary_acting'], 'head': ['head_id', 'age'] }
TABLE head ( head.head_ID (INT), head.age (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), )
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.
extra
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT head.born_state FROM department JOIN management ON department.department_id = management.department_id JOIN head ON management.head_id = head.head_id WHERE department.name = 'Treasury' INTERSECT SELECT head.born_state FROM department JOIN management ON department.department_id = management.department_id JOIN head ON management.head_id = head.head_id WHERE department.name = 'Homeland Security'
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'department': ['department_id', 'name'], 'management': ['department_id', 'head_id'], 'head': ['head_id', 'born_state'] }
TABLE department ( department.Department_ID (INT), department.Name (TEXT), ) TABLE head ( head.head_ID (INT), head.born_state (TEXT), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), )
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
Which department has more than 1 head at a time? List the id, name and the number of heads.
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT department.department_id , department.name , count(*) FROM management JOIN department ON department.department_id = management.department_id GROUP BY department.department_id HAVING count(*) > 1
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'management': ['department_id'], 'department': ['department_id', 'name'] }
TABLE department ( department.Department_ID (INT), department.Name (TEXT), ) TABLE management ( management.department_ID (INT), )
TABLE department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) TABLE management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
department_management
Which head's name has the substring 'Ha'? List the id and name.
medium
Table department ( department.Department_ID (INT), department.Name (TEXT), department.Creation (TEXT), department.Ranking (INT), department.Budget_in_Billions (REAL), department.Num_Employees (REAL), ) Table head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_ID (INT), management.head_ID (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_ID = department.Department_ID management.head_ID = head.head_ID
SELECT head_id , name FROM head WHERE name LIKE '%Ha%'
Table department ( department.department_id (INT), department.name (TEXT), department.creation (TEXT), department.ranking (INT), department.budget_in_billions (REAL), department.num_employees (REAL), ) Table head ( head.head_id (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Table management ( management.department_id (INT), management.head_id (INT), management.temporary_acting (TEXT), ) Possible JOINs: management.department_id = department.department_id management.head_id = head.head_id
{ 'department': ['department_id', 'name', 'creation', 'ranking', 'budget_in_billions', 'num_employees'], 'head': ['head_id', 'name', 'born_state', 'age'], 'management': ['department_id', 'head_id', 'temporary_acting'] }
{ 'head': ['head_id', 'name'] }
TABLE head ( head.head_ID (INT), head.name (TEXT), ) Possible JOINs:
TABLE head ( head.head_ID (INT), head.name (TEXT), head.born_state (TEXT), head.age (REAL), ) Possible JOINs:
farm
How many farms are there?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT count(*) FROM farm
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id'] }
TABLE farm ( farm.Farm_ID (INT), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
Count the number of farms.
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT count(*) FROM farm
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id'] }
TABLE farm ( farm.Farm_ID (INT), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
List the total number of horses on farms in ascending order.
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id', 'total_horses'] }
TABLE farm ( farm.Farm_ID (INT), farm.Total_Horses (REAL), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
What is the total horses record for each farm, sorted ascending?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id', 'total_horses'] }
TABLE farm ( farm.Farm_ID (INT), farm.Total_Horses (REAL), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
What are the hosts of competitions whose theme is not "Aliens"?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens'
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm_competition': ['competition_id', 'theme', 'hosts'] }
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Theme (TEXT), farm_competition.Hosts (TEXT), )
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Return the hosts of competitions for which the theme is not Aliens?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens'
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm_competition': ['competition_id', 'theme', 'hosts'] }
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Theme (TEXT), farm_competition.Hosts (TEXT), )
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
What are the themes of farm competitions sorted by year in ascending order?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Theme FROM farm_competition ORDER BY YEAR ASC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm_competition': ['competition_id', 'year', 'theme'] }
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), )
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Return the themes of farm competitions, sorted by year ascending.
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Theme FROM farm_competition ORDER BY YEAR ASC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm_competition': ['competition_id', 'year', 'theme'] }
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), )
TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
What is the average number of working horses of farms with more than 5000 total number of horses?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT avg(Working_Horses) FROM farm WHERE Total_Horses > 5000
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id', 'total_horses', 'working_horses'] }
TABLE farm ( farm.Farm_ID (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
Give the average number of working horses on farms with more than 5000 total horses.
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT avg(Working_Horses) FROM farm WHERE Total_Horses > 5000
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id', 'total_horses', 'working_horses'] }
TABLE farm ( farm.Farm_ID (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
What are the maximum and minimum number of cows across all farms.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT max(Cows) , min(Cows) FROM farm
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id', 'cows'] }
TABLE farm ( farm.Farm_ID (INT), farm.Cows (REAL), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
Return the maximum and minimum number of cows across all farms.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT max(Cows) , min(Cows) FROM farm
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'farm': ['farm_id', 'cows'] }
TABLE farm ( farm.Farm_ID (INT), farm.Cows (REAL), ) Possible JOINs:
TABLE farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Possible JOINs:
farm
How many different statuses do cities have?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT count(DISTINCT Status) FROM city
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Count the number of different statuses.
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT count(DISTINCT Status) FROM city
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
List official names of cities in descending order of population.
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name FROM city ORDER BY Population DESC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name', 'population'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
What are the official names of cities, ordered descending by population?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name FROM city ORDER BY Population DESC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name', 'population'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
List the official name and status of the city with the largest population.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name', 'status', 'population'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
What is the official name and status of the city with the most residents?
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name', 'status', 'population'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Show the years and the official names of the host cities of competitions.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT farm_competition.Year , city.Official_Name FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name'], 'farm_competition': ['competition_id', 'year', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Give the years and official names of the cities of each competition.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT farm_competition.Year , city.Official_Name FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name'], 'farm_competition': ['competition_id', 'year', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Show the official names of the cities that have hosted more than one competition.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT city.Official_Name FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID GROUP BY farm_competition.Host_city_ID HAVING COUNT(*) > 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name'], 'farm_competition': ['competition_id', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
What are the official names of cities that have hosted more than one competition?
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT city.Official_Name FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID GROUP BY farm_competition.Host_city_ID HAVING COUNT(*) > 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name'], 'farm_competition': ['competition_id', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Show the status of the city that has hosted the greatest number of competitions.
extra
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT city.Status FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID GROUP BY farm_competition.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'], 'farm_competition': ['competition_id', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
What is the status of the city that has hosted the most competitions?
extra
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT city.Status FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID GROUP BY farm_competition.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'], 'farm_competition': ['competition_id', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Please show the themes of competitions with host cities having populations larger than 1000.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT farm_competition.Theme FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID WHERE city.Population > 1000
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'population'], 'farm_competition': ['competition_id', 'theme', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Population (REAL), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
What are the themes of competitions that have corresponding host cities with more than 1000 residents?
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT farm_competition.Theme FROM city JOIN farm_competition ON city.City_ID = farm_competition.Host_city_ID WHERE city.Population > 1000
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'population'], 'farm_competition': ['competition_id', 'theme', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Population (REAL), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Please show the different statuses of cities and the average population of cities with each status.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status , avg(Population) FROM city GROUP BY Status
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status', 'population'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
What are the statuses and average populations of each city?
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status , avg(Population) FROM city GROUP BY Status
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status', 'population'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Please show the different statuses, ordered by the number of cities that have each.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Return the different statuses of cities, ascending by frequency.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
List the most common type of Status across cities.
hard
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
What is the most common status across all cities?
hard
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
List the official names of cities that have not held any competition.
hard
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition)
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name'], 'farm_competition': ['competition_id', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
What are the official names of cities that have not hosted a farm competition?
hard
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition)
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name'], 'farm_competition': ['competition_id', 'host_city_id'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Host_city_ID (INT), )
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) TABLE farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: farm_competition.Host_city_ID = city.City_ID
farm
Show the status shared by cities with population bigger than 1500 and smaller than 500.
hard
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status FROM city WHERE Population > 1500 INTERSECT SELECT Status FROM city WHERE Population < 500
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status', 'population'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Which statuses correspond to both cities that have a population over 1500 and cities that have a population lower than 500?
hard
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Status FROM city WHERE Population > 1500 INTERSECT SELECT Status FROM city WHERE Population < 500
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status', 'population'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Find the official names of cities with population bigger than 1500 or smaller than 500.
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name', 'population'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
What are the official names of cities that have population over 1500 or less than 500?
medium
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'official_name', 'population'] }
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Population (REAL), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
Show the census ranking of cities whose status are not "Village".
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Census_Ranking FROM city WHERE Status != "Village"
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status', 'census_ranking'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), city.Census_Ranking (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
farm
What are the census rankings of cities that do not have the status "Village"?
easy
Table city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Table competition_record ( competition_record.Competition_ID (INT), competition_record.Farm_ID (INT), competition_record.Rank (INT), ) Table farm ( farm.Farm_ID (INT), farm.Year (INT), farm.Total_Horses (REAL), farm.Working_Horses (REAL), farm.Total_Cattle (REAL), farm.Oxen (REAL), farm.Bulls (REAL), farm.Cows (REAL), farm.Pigs (REAL), farm.Sheep_and_Goats (REAL), ) Table farm_competition ( farm_competition.Competition_ID (INT), farm_competition.Year (INT), farm_competition.Theme (TEXT), farm_competition.Host_city_ID (INT), farm_competition.Hosts (TEXT), ) Possible JOINs: competition_record.Competition_ID = farm_competition.Competition_ID competition_record.Farm_ID = farm.Farm_ID farm_competition.Host_city_ID = city.City_ID
SELECT Census_Ranking FROM city WHERE Status != "Village"
Table city ( city.city_id (INT), city.official_name (TEXT), city.status (TEXT), city.area_km_2 (REAL), city.population (REAL), city.census_ranking (TEXT), ) Table competition_record ( competition_record.competition_id (INT), competition_record.farm_id (INT), competition_record.rank (INT), ) Table farm ( farm.farm_id (INT), farm.year (INT), farm.total_horses (REAL), farm.working_horses (REAL), farm.total_cattle (REAL), farm.oxen (REAL), farm.bulls (REAL), farm.cows (REAL), farm.pigs (REAL), farm.sheep_and_goats (REAL), ) Table farm_competition ( farm_competition.competition_id (INT), farm_competition.year (INT), farm_competition.theme (TEXT), farm_competition.host_city_id (INT), farm_competition.hosts (TEXT), ) Possible JOINs: competition_record.competition_id = farm_competition.competition_id competition_record.farm_id = farm.farm_id farm_competition.host_city_id = city.city_id
{ 'city': ['city_id', 'official_name', 'status', 'area_km_2', 'population', 'census_ranking'], 'farm': ['farm_id', 'year', 'total_horses', 'working_horses', 'total_cattle', 'oxen', 'bulls', 'cows', 'pigs', 'sheep_and_goats'], 'farm_competition': ['competition_id', 'year', 'theme', 'host_city_id', 'hosts'], 'competition_record': ['competition_id', 'farm_id', 'rank'] }
{ 'city': ['city_id', 'status', 'census_ranking'] }
TABLE city ( city.City_ID (INT), city.Status (TEXT), city.Census_Ranking (TEXT), ) Possible JOINs:
TABLE city ( city.City_ID (INT), city.Official_Name (TEXT), city.Status (TEXT), city.Area_km_2 (REAL), city.Population (REAL), city.Census_Ranking (TEXT), ) Possible JOINs:
student_assessment
which course has most number of registered students?
extra
Table Addresses ( Addresses.address_id (INTEGER), Addresses.line_1 (VARCHAR(80)), Addresses.line_2 (VARCHAR(80)), Addresses.city (VARCHAR(50)), Addresses.zip_postcode (CHAR(20)), Addresses.state_province_county (VARCHAR(50)), Addresses.country (VARCHAR(50)), ) Table Candidate_Assessments ( Candidate_Assessments.candidate_id (INTEGER), Candidate_Assessments.qualification (CHAR(15)), Candidate_Assessments.assessment_date (DATETIME), Candidate_Assessments.asessment_outcome_code (CHAR(15)), ) Table Candidates ( Candidates.candidate_id (INTEGER), Candidates.candidate_details (VARCHAR(255)), ) Table Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), Courses.course_description (VARCHAR(255)), Courses.other_details (VARCHAR(255)), ) Table People ( People.person_id (INTEGER), People.first_name (VARCHAR(255)), People.middle_name (VARCHAR(255)), People.last_name (VARCHAR(255)), People.cell_mobile_number (VARCHAR(40)), People.email_address (VARCHAR(40)), People.login_name (VARCHAR(40)), People.password (VARCHAR(40)), ) Table People_Addresses ( People_Addresses.person_address_id (INTEGER), People_Addresses.person_id (INTEGER), People_Addresses.address_id (INTEGER), People_Addresses.date_from (DATETIME), People_Addresses.date_to (DATETIME), ) Table Student_Course_Attendance ( Student_Course_Attendance.student_id (INTEGER), Student_Course_Attendance.course_id (INTEGER), Student_Course_Attendance.date_of_attendance (DATETIME), ) Table Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), Student_Course_Registrations.registration_date (DATETIME), ) Table Students ( Students.student_id (INTEGER), Students.student_details (VARCHAR(255)), ) Possible JOINs: Candidate_Assessments.candidate_id = Candidates.candidate_id Candidates.candidate_id = People.person_id People_Addresses.person_id = People.person_id People_Addresses.address_id = Addresses.address_id Student_Course_Attendance.student_id = Student_Course_Registrations.student_id Student_Course_Attendance.course_id = Student_Course_Registrations.course_id Student_Course_Registrations.student_id = Students.student_id Student_Course_Registrations.course_id = Courses.course_id Students.student_id = People.person_id
SELECT courses.course_name FROM courses JOIN student_course_registrations ON courses.course_id = student_course_registrations.course_Id GROUP BY courses.course_id ORDER BY count(*) DESC LIMIT 1
Table addresses ( addresses.address_id (INTEGER), addresses.line_1 (VARCHAR(80)), addresses.line_2 (VARCHAR(80)), addresses.city (VARCHAR(50)), addresses.zip_postcode (CHAR(20)), addresses.state_province_county (VARCHAR(50)), addresses.country (VARCHAR(50)), ) Table candidate_assessments ( candidate_assessments.candidate_id (INTEGER), candidate_assessments.qualification (CHAR(15)), candidate_assessments.assessment_date (DATETIME), candidate_assessments.asessment_outcome_code (CHAR(15)), ) Table candidates ( candidates.candidate_id (INTEGER), candidates.candidate_details (VARCHAR(255)), ) Table courses ( courses.course_id (VARCHAR(100)), courses.course_name (VARCHAR(120)), courses.course_description (VARCHAR(255)), courses.other_details (VARCHAR(255)), ) Table people ( people.person_id (INTEGER), people.first_name (VARCHAR(255)), people.middle_name (VARCHAR(255)), people.last_name (VARCHAR(255)), people.cell_mobile_number (VARCHAR(40)), people.email_address (VARCHAR(40)), people.login_name (VARCHAR(40)), people.password (VARCHAR(40)), ) Table people_addresses ( people_addresses.person_address_id (INTEGER), people_addresses.person_id (INTEGER), people_addresses.address_id (INTEGER), people_addresses.date_from (DATETIME), people_addresses.date_to (DATETIME), ) Table student_course_attendance ( student_course_attendance.student_id (INTEGER), student_course_attendance.course_id (INTEGER), student_course_attendance.date_of_attendance (DATETIME), ) Table student_course_registrations ( student_course_registrations.student_id (INTEGER), student_course_registrations.course_id (INTEGER), student_course_registrations.registration_date (DATETIME), ) Table students ( students.student_id (INTEGER), students.student_details (VARCHAR(255)), ) Possible JOINs: candidate_assessments.candidate_id = candidates.candidate_id candidates.candidate_id = people.person_id people_addresses.person_id = people.person_id people_addresses.address_id = addresses.address_id student_course_attendance.student_id = student_course_registrations.student_id student_course_attendance.course_id = student_course_registrations.course_id student_course_registrations.student_id = students.student_id student_course_registrations.course_id = courses.course_id students.student_id = people.person_id
{ 'addresses': ['address_id', 'line_1', 'line_2', 'city', 'zip_postcode', 'state_province_county', 'country'], 'people': ['person_id', 'first_name', 'middle_name', 'last_name', 'cell_mobile_number', 'email_address', 'login_name', 'password'], 'students': ['student_id', 'student_details'], 'courses': ['course_id', 'course_name', 'course_description', 'other_details'], 'people_addresses': ['person_address_id', 'person_id', 'address_id', 'date_from', 'date_to'], 'student_course_registrations': ['student_id', 'course_id', 'registration_date'], 'student_course_attendance': ['student_id', 'course_id', 'date_of_attendance'], 'candidates': ['candidate_id', 'candidate_details'], 'candidate_assessments': ['candidate_id', 'qualification', 'assessment_date', 'asessment_outcome_code'] }
{ 'courses': ['course_id', 'course_name'], 'student_course_registrations': ['student_id', 'course_id'] }
TABLE Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), ) TABLE Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), ) Possible JOINs: Student_Course_Registrations.course_id = Courses.course_id
TABLE Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), Courses.course_description (VARCHAR(255)), Courses.other_details (VARCHAR(255)), ) TABLE Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), Student_Course_Registrations.registration_date (DATETIME), ) Possible JOINs: Student_Course_Registrations.student_id = Students.student_id Student_Course_Registrations.course_id = Courses.course_id
student_assessment
What is the name of the course with the most registered students?
extra
Table Addresses ( Addresses.address_id (INTEGER), Addresses.line_1 (VARCHAR(80)), Addresses.line_2 (VARCHAR(80)), Addresses.city (VARCHAR(50)), Addresses.zip_postcode (CHAR(20)), Addresses.state_province_county (VARCHAR(50)), Addresses.country (VARCHAR(50)), ) Table Candidate_Assessments ( Candidate_Assessments.candidate_id (INTEGER), Candidate_Assessments.qualification (CHAR(15)), Candidate_Assessments.assessment_date (DATETIME), Candidate_Assessments.asessment_outcome_code (CHAR(15)), ) Table Candidates ( Candidates.candidate_id (INTEGER), Candidates.candidate_details (VARCHAR(255)), ) Table Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), Courses.course_description (VARCHAR(255)), Courses.other_details (VARCHAR(255)), ) Table People ( People.person_id (INTEGER), People.first_name (VARCHAR(255)), People.middle_name (VARCHAR(255)), People.last_name (VARCHAR(255)), People.cell_mobile_number (VARCHAR(40)), People.email_address (VARCHAR(40)), People.login_name (VARCHAR(40)), People.password (VARCHAR(40)), ) Table People_Addresses ( People_Addresses.person_address_id (INTEGER), People_Addresses.person_id (INTEGER), People_Addresses.address_id (INTEGER), People_Addresses.date_from (DATETIME), People_Addresses.date_to (DATETIME), ) Table Student_Course_Attendance ( Student_Course_Attendance.student_id (INTEGER), Student_Course_Attendance.course_id (INTEGER), Student_Course_Attendance.date_of_attendance (DATETIME), ) Table Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), Student_Course_Registrations.registration_date (DATETIME), ) Table Students ( Students.student_id (INTEGER), Students.student_details (VARCHAR(255)), ) Possible JOINs: Candidate_Assessments.candidate_id = Candidates.candidate_id Candidates.candidate_id = People.person_id People_Addresses.person_id = People.person_id People_Addresses.address_id = Addresses.address_id Student_Course_Attendance.student_id = Student_Course_Registrations.student_id Student_Course_Attendance.course_id = Student_Course_Registrations.course_id Student_Course_Registrations.student_id = Students.student_id Student_Course_Registrations.course_id = Courses.course_id Students.student_id = People.person_id
SELECT courses.course_name FROM courses JOIN student_course_registrations ON courses.course_id = student_course_registrations.course_Id GROUP BY courses.course_id ORDER BY count(*) DESC LIMIT 1
Table addresses ( addresses.address_id (INTEGER), addresses.line_1 (VARCHAR(80)), addresses.line_2 (VARCHAR(80)), addresses.city (VARCHAR(50)), addresses.zip_postcode (CHAR(20)), addresses.state_province_county (VARCHAR(50)), addresses.country (VARCHAR(50)), ) Table candidate_assessments ( candidate_assessments.candidate_id (INTEGER), candidate_assessments.qualification (CHAR(15)), candidate_assessments.assessment_date (DATETIME), candidate_assessments.asessment_outcome_code (CHAR(15)), ) Table candidates ( candidates.candidate_id (INTEGER), candidates.candidate_details (VARCHAR(255)), ) Table courses ( courses.course_id (VARCHAR(100)), courses.course_name (VARCHAR(120)), courses.course_description (VARCHAR(255)), courses.other_details (VARCHAR(255)), ) Table people ( people.person_id (INTEGER), people.first_name (VARCHAR(255)), people.middle_name (VARCHAR(255)), people.last_name (VARCHAR(255)), people.cell_mobile_number (VARCHAR(40)), people.email_address (VARCHAR(40)), people.login_name (VARCHAR(40)), people.password (VARCHAR(40)), ) Table people_addresses ( people_addresses.person_address_id (INTEGER), people_addresses.person_id (INTEGER), people_addresses.address_id (INTEGER), people_addresses.date_from (DATETIME), people_addresses.date_to (DATETIME), ) Table student_course_attendance ( student_course_attendance.student_id (INTEGER), student_course_attendance.course_id (INTEGER), student_course_attendance.date_of_attendance (DATETIME), ) Table student_course_registrations ( student_course_registrations.student_id (INTEGER), student_course_registrations.course_id (INTEGER), student_course_registrations.registration_date (DATETIME), ) Table students ( students.student_id (INTEGER), students.student_details (VARCHAR(255)), ) Possible JOINs: candidate_assessments.candidate_id = candidates.candidate_id candidates.candidate_id = people.person_id people_addresses.person_id = people.person_id people_addresses.address_id = addresses.address_id student_course_attendance.student_id = student_course_registrations.student_id student_course_attendance.course_id = student_course_registrations.course_id student_course_registrations.student_id = students.student_id student_course_registrations.course_id = courses.course_id students.student_id = people.person_id
{ 'addresses': ['address_id', 'line_1', 'line_2', 'city', 'zip_postcode', 'state_province_county', 'country'], 'people': ['person_id', 'first_name', 'middle_name', 'last_name', 'cell_mobile_number', 'email_address', 'login_name', 'password'], 'students': ['student_id', 'student_details'], 'courses': ['course_id', 'course_name', 'course_description', 'other_details'], 'people_addresses': ['person_address_id', 'person_id', 'address_id', 'date_from', 'date_to'], 'student_course_registrations': ['student_id', 'course_id', 'registration_date'], 'student_course_attendance': ['student_id', 'course_id', 'date_of_attendance'], 'candidates': ['candidate_id', 'candidate_details'], 'candidate_assessments': ['candidate_id', 'qualification', 'assessment_date', 'asessment_outcome_code'] }
{ 'courses': ['course_id', 'course_name'], 'student_course_registrations': ['student_id', 'course_id'] }
TABLE Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), ) TABLE Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), ) Possible JOINs: Student_Course_Registrations.course_id = Courses.course_id
TABLE Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), Courses.course_description (VARCHAR(255)), Courses.other_details (VARCHAR(255)), ) TABLE Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), Student_Course_Registrations.registration_date (DATETIME), ) Possible JOINs: Student_Course_Registrations.student_id = Students.student_id Student_Course_Registrations.course_id = Courses.course_id
student_assessment
what is id of students who registered some courses but the least number of courses in these students?
hard
Table Addresses ( Addresses.address_id (INTEGER), Addresses.line_1 (VARCHAR(80)), Addresses.line_2 (VARCHAR(80)), Addresses.city (VARCHAR(50)), Addresses.zip_postcode (CHAR(20)), Addresses.state_province_county (VARCHAR(50)), Addresses.country (VARCHAR(50)), ) Table Candidate_Assessments ( Candidate_Assessments.candidate_id (INTEGER), Candidate_Assessments.qualification (CHAR(15)), Candidate_Assessments.assessment_date (DATETIME), Candidate_Assessments.asessment_outcome_code (CHAR(15)), ) Table Candidates ( Candidates.candidate_id (INTEGER), Candidates.candidate_details (VARCHAR(255)), ) Table Courses ( Courses.course_id (VARCHAR(100)), Courses.course_name (VARCHAR(120)), Courses.course_description (VARCHAR(255)), Courses.other_details (VARCHAR(255)), ) Table People ( People.person_id (INTEGER), People.first_name (VARCHAR(255)), People.middle_name (VARCHAR(255)), People.last_name (VARCHAR(255)), People.cell_mobile_number (VARCHAR(40)), People.email_address (VARCHAR(40)), People.login_name (VARCHAR(40)), People.password (VARCHAR(40)), ) Table People_Addresses ( People_Addresses.person_address_id (INTEGER), People_Addresses.person_id (INTEGER), People_Addresses.address_id (INTEGER), People_Addresses.date_from (DATETIME), People_Addresses.date_to (DATETIME), ) Table Student_Course_Attendance ( Student_Course_Attendance.student_id (INTEGER), Student_Course_Attendance.course_id (INTEGER), Student_Course_Attendance.date_of_attendance (DATETIME), ) Table Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), Student_Course_Registrations.registration_date (DATETIME), ) Table Students ( Students.student_id (INTEGER), Students.student_details (VARCHAR(255)), ) Possible JOINs: Candidate_Assessments.candidate_id = Candidates.candidate_id Candidates.candidate_id = People.person_id People_Addresses.person_id = People.person_id People_Addresses.address_id = Addresses.address_id Student_Course_Attendance.student_id = Student_Course_Registrations.student_id Student_Course_Attendance.course_id = Student_Course_Registrations.course_id Student_Course_Registrations.student_id = Students.student_id Student_Course_Registrations.course_id = Courses.course_id Students.student_id = People.person_id
SELECT student_id FROM student_course_registrations GROUP BY student_id ORDER BY count(*) LIMIT 1
Table addresses ( addresses.address_id (INTEGER), addresses.line_1 (VARCHAR(80)), addresses.line_2 (VARCHAR(80)), addresses.city (VARCHAR(50)), addresses.zip_postcode (CHAR(20)), addresses.state_province_county (VARCHAR(50)), addresses.country (VARCHAR(50)), ) Table candidate_assessments ( candidate_assessments.candidate_id (INTEGER), candidate_assessments.qualification (CHAR(15)), candidate_assessments.assessment_date (DATETIME), candidate_assessments.asessment_outcome_code (CHAR(15)), ) Table candidates ( candidates.candidate_id (INTEGER), candidates.candidate_details (VARCHAR(255)), ) Table courses ( courses.course_id (VARCHAR(100)), courses.course_name (VARCHAR(120)), courses.course_description (VARCHAR(255)), courses.other_details (VARCHAR(255)), ) Table people ( people.person_id (INTEGER), people.first_name (VARCHAR(255)), people.middle_name (VARCHAR(255)), people.last_name (VARCHAR(255)), people.cell_mobile_number (VARCHAR(40)), people.email_address (VARCHAR(40)), people.login_name (VARCHAR(40)), people.password (VARCHAR(40)), ) Table people_addresses ( people_addresses.person_address_id (INTEGER), people_addresses.person_id (INTEGER), people_addresses.address_id (INTEGER), people_addresses.date_from (DATETIME), people_addresses.date_to (DATETIME), ) Table student_course_attendance ( student_course_attendance.student_id (INTEGER), student_course_attendance.course_id (INTEGER), student_course_attendance.date_of_attendance (DATETIME), ) Table student_course_registrations ( student_course_registrations.student_id (INTEGER), student_course_registrations.course_id (INTEGER), student_course_registrations.registration_date (DATETIME), ) Table students ( students.student_id (INTEGER), students.student_details (VARCHAR(255)), ) Possible JOINs: candidate_assessments.candidate_id = candidates.candidate_id candidates.candidate_id = people.person_id people_addresses.person_id = people.person_id people_addresses.address_id = addresses.address_id student_course_attendance.student_id = student_course_registrations.student_id student_course_attendance.course_id = student_course_registrations.course_id student_course_registrations.student_id = students.student_id student_course_registrations.course_id = courses.course_id students.student_id = people.person_id
{ 'addresses': ['address_id', 'line_1', 'line_2', 'city', 'zip_postcode', 'state_province_county', 'country'], 'people': ['person_id', 'first_name', 'middle_name', 'last_name', 'cell_mobile_number', 'email_address', 'login_name', 'password'], 'students': ['student_id', 'student_details'], 'courses': ['course_id', 'course_name', 'course_description', 'other_details'], 'people_addresses': ['person_address_id', 'person_id', 'address_id', 'date_from', 'date_to'], 'student_course_registrations': ['student_id', 'course_id', 'registration_date'], 'student_course_attendance': ['student_id', 'course_id', 'date_of_attendance'], 'candidates': ['candidate_id', 'candidate_details'], 'candidate_assessments': ['candidate_id', 'qualification', 'assessment_date', 'asessment_outcome_code'] }
{ 'student_course_registrations': ['student_id'] }
TABLE Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), )
TABLE Student_Course_Registrations ( Student_Course_Registrations.student_id (INTEGER), Student_Course_Registrations.course_id (INTEGER), Student_Course_Registrations.registration_date (DATETIME), ) Possible JOINs: Student_Course_Registrations.student_id = Students.student_id Student_Course_Registrations.course_id = Courses.course_id
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
15
Edit dataset card