prompt
stringlengths 25
117
| chosen
stringlengths 25
378
| rejected
stringlengths 26
285
|
---|---|---|
How many heads of the departments are older than 56 ? | SELECT count(*) FROM head WHERE age > 56 | SELECT COUNT(*) FROM department_heads WHERE age > 56; |
List the name, born state and age of the heads of departments ordered by age. | SELECT name , born_state , age FROM head ORDER BY age | SELECT name, born_state, age FROM heads_of_departments ORDER BY age; |
List the creation year, name and budget of each department. | SELECT creation , name , budget_in_billions FROM department | SELECT creation_year, name, budget FROM department; |
What are the maximum and minimum budget of the departments? | SELECT max(budget_in_billions) , min(budget_in_billions) FROM department | SELECT MAX(budget) AS max_budget, MIN(budget) AS min_budget FROM departments; |
What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'? | SELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T3.born_state = 'Alabama' | SELECT DISTINCT departments.creation_year
FROM departments
JOIN secretaries ON departments.secretary_id = secretaries.id
WHERE secretaries.birth_state = 'Alabama'; |
What are the names of the states where at least 3 heads were born? | SELECT born_state FROM head GROUP BY born_state HAVING count(*) >= 3 | SELECT state_name
FROM states
WHERE (SELECT COUNT(*) FROM heads WHERE heads.state_id = states.state_id) >= 3; |
In which year were most departments established? | SELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1 | SELECT year_established, COUNT(*) AS num_departments
FROM departments
GROUP BY year_established
ORDER BY num_departments DESC
LIMIT 1 |
Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'? | SELECT T1.name , T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id WHERE T2.temporary_acting = 'Yes' | SELECT departments.name, COUNT(employees.id) AS number_of_employees
FROM departments
JOIN employees ON departments.id = employees.department_id
JOIN department_heads ON departments.head_id = department_heads.id
WHERE department_heads.temporary_acting = 'Yes'
GROUP BY departments.name; |
How many acting statuses are there? | SELECT count(DISTINCT temporary_acting) FROM management | SELECT COUNT(DISTINCT acting_status) FROM actors; |
How many departments are led by heads who are not mentioned? | SELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management); | SELECT COUNT(*) FROM departments WHERE head IS NULL; |
What are the distinct ages of the heads who are acting? | SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id = T2.head_id WHERE T2.temporary_acting = 'Yes' | SELECT DISTINCT age FROM heads WHERE status = 'acting'; |
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born. | SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Homeland Security' | SELECT state_of_birth
FROM secretaries
WHERE department = 'Treasury'
INTERSECT
SELECT state_of_birth
FROM secretaries
WHERE department = 'Homeland Security'; |
Which department has more than 1 head at a time? List the id, name and the number of heads. | SELECT T1.department_id , T1.name , count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id = T2.department_id GROUP BY T1.department_id HAVING count(*) > 1 | SELECT department_id, department_name, COUNT(head_id) AS number_of_heads
FROM departments
JOIN department_heads ON departments.department_id = department_heads.department_id
GROUP BY department_id, department_name
HAVING COUNT(head_id) > 1; |
How many farms are there? | SELECT count(*) FROM farm | SELECT COUNT(*) FROM farms; |
Count the number of farms. | SELECT count(*) FROM farm | SELECT COUNT(*) FROM farms |
List the total number of horses on farms in ascending order. | SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC | SELECT farm_id, COUNT(horse_id) AS total_horses
FROM horses
GROUP BY farm_id
ORDER BY total_horses ASC; |
What is the total horses record for each farm, sorted ascending? | SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC | SELECT farm_id, COUNT(horse_id) AS total_horses
FROM horses
GROUP BY farm_id
ORDER BY total_horses ASC; |
What are the hosts of competitions whose theme is not "Aliens"? | SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens' | SELECT host
FROM competitions
WHERE theme <> 'Aliens'; |
What are the themes of farm competitions sorted by year in ascending order? | SELECT Theme FROM farm_competition ORDER BY YEAR ASC | SELECT year, theme FROM farm_competitions ORDER BY year ASC; |
What are the maximum and minimum number of cows across all farms. | SELECT max(Cows) , min(Cows) FROM farm | SELECT MAX(number_of_cows) AS max_cows, MIN(number_of_cows) AS min_cows FROM farms; |
Return the maximum and minimum number of cows across all farms. | SELECT max(Cows) , min(Cows) FROM farm | SELECT MAX(number_of_cows), MIN(number_of_cows) FROM farms; |
How many different statuses do cities have? | SELECT count(DISTINCT Status) FROM city | SELECT COUNT(DISTINCT status) FROM cities; |
Count the number of different statuses. | SELECT count(DISTINCT Status) FROM city | SELECT COUNT(DISTINCT status) FROM table_name; |
Show the years and the official names of the host cities of competitions. | SELECT T2.Year , T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID | SELECT year, city_official_name FROM competitions; |
Give the years and official names of the cities of each competition. | SELECT T2.Year , T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID | SELECT competitions.year, cities.official_name
FROM competitions
JOIN cities ON competitions.city_id = cities.id; |
Show the official names of the cities that have hosted more than one competition. | SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1 | SELECT city_official_name FROM competitions GROUP BY city_official_name HAVING COUNT(DISTINCT competition_id) > 1; |
What are the official names of cities that have hosted more than one competition? | SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1 | SELECT official_name FROM cities WHERE hosted_competitions > 1; |
Show the status of the city that has hosted the greatest number of competitions. | SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1 | SELECT city, status
FROM competitions
GROUP BY city
ORDER BY COUNT(*) DESC
LIMIT 1; |
What is the status of the city that has hosted the most competitions? | SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1 | SELECT status
FROM city
WHERE id = (
SELECT city_id
FROM competitions
GROUP BY city_id
ORDER BY COUNT(*) DESC
LIMIT 1
) |
Please show the themes of competitions with host cities having populations larger than 1000. | SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000 | SELECT c.theme
FROM competitions c
JOIN cities ci ON c.host_city_id = ci.city_id
WHERE ci.population > 1000; |
What are the themes of competitions that have corresponding host cities with more than 1000 residents? | SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000 | SELECT DISTINCT competition_theme
FROM competitions
JOIN host_cities ON competitions.host_city_id = host_cities.id
WHERE host_cities.population > 1000; |
Please show the different statuses of cities and the average population of cities with each status. | SELECT Status , avg(Population) FROM city GROUP BY Status | SELECT status, AVG(population) AS average_population
FROM cities
GROUP BY status; |
What are the statuses and average populations of each city? | SELECT Status , avg(Population) FROM city GROUP BY Status | SELECT status, AVG(population) as average_population FROM cities GROUP BY status; |
Please show the different statuses, ordered by the number of cities that have each. | SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC | SELECT status, COUNT(DISTINCT city) AS city_count
FROM your_table_name
GROUP BY status
ORDER BY city_count DESC; |
Return the different statuses of cities, ascending by frequency. | SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC | SELECT status, COUNT(*) AS frequency FROM cities GROUP BY status ORDER BY frequency ASC; |
List the most common type of Status across cities. | SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1 | SELECT Status, COUNT(Status) AS StatusCount
FROM table_name
GROUP BY Status
ORDER BY StatusCount DESC
LIMIT 1; |
What is the most common status across all cities? | SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1 | SELECT status, COUNT(*) as count
FROM table_name
GROUP BY status
ORDER BY count DESC
LIMIT 1; |
List the official names of cities that have not held any competition. | SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition) | SELECT city_official_name
FROM cities
WHERE city_id NOT IN (
SELECT DISTINCT city_id
FROM competitions
); |
What are the official names of cities that have not hosted a farm competition? | SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition) | SELECT city_name FROM cities WHERE city_id NOT IN (SELECT city_id FROM farm_competitions); |
README.md exists but content is empty.
- Downloads last month
- 43