messages
list |
---|
[
{
"content": "How many colors are never used by any product?",
"role": "user"
},
{
"content": "SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products )",
"role": "assistant"
}
]
|
[
{
"content": "Count the number of colors that are not used in any products.",
"role": "user"
},
{
"content": "SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products )",
"role": "assistant"
}
]
|
[
{
"content": "How many events are there?",
"role": "user"
},
{
"content": "SELECT count(*) FROM event",
"role": "assistant"
}
]
|
[
{
"content": "List all the event names by year from the most recent to the oldest.",
"role": "user"
},
{
"content": "SELECT name FROM event ORDER BY YEAR DESC",
"role": "assistant"
}
]
|
[
{
"content": "What is the name of the event that happened in the most recent year?",
"role": "user"
},
{
"content": "SELECT name FROM event ORDER BY YEAR DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "How many stadiums are there?",
"role": "user"
},
{
"content": "SELECT count(*) FROM stadium",
"role": "assistant"
}
]
|
[
{
"content": "Find the name of the stadium that has the maximum capacity.",
"role": "user"
},
{
"content": "SELECT name FROM stadium ORDER BY capacity DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of stadiums whose capacity is smaller than the average capacity.",
"role": "user"
},
{
"content": "SELECT name FROM stadium WHERE capacity < (SELECT avg(capacity) FROM stadium)",
"role": "assistant"
}
]
|
[
{
"content": "Find the country that has the most stadiums.",
"role": "user"
},
{
"content": "SELECT country FROM stadium GROUP BY country ORDER BY count(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Which country has at most 3 stadiums listed?",
"role": "user"
},
{
"content": "SELECT country FROM stadium GROUP BY country HAVING count(*) <= 3",
"role": "assistant"
}
]
|
[
{
"content": "Which country has both stadiums with capacity greater than 60000 and stadiums with capacity less than 50000?",
"role": "user"
},
{
"content": "SELECT country FROM stadium WHERE capacity > 60000 INTERSECT SELECT country FROM stadium WHERE capacity < 50000",
"role": "assistant"
}
]
|
[
{
"content": "How many cities have a stadium that was opened before the year of 2006?",
"role": "user"
},
{
"content": "SELECT count(DISTINCT city) FROM stadium WHERE opening_year < 2006",
"role": "assistant"
}
]
|
[
{
"content": "How many stadiums does each country have?",
"role": "user"
},
{
"content": "SELECT country , count(*) FROM stadium GROUP BY country",
"role": "assistant"
}
]
|
[
{
"content": "Which countries do not have a stadium that was opened after 2006?",
"role": "user"
},
{
"content": "SELECT country FROM stadium EXCEPT SELECT country FROM stadium WHERE opening_year > 2006",
"role": "assistant"
}
]
|
[
{
"content": "How many stadiums are not in country \"Russia\"?",
"role": "user"
},
{
"content": "SELECT count(*) FROM stadium WHERE country != 'Russia'",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of all swimmers, sorted by their 100 meter scores in ascending order.",
"role": "user"
},
{
"content": "SELECT name FROM swimmer ORDER BY meter_100",
"role": "assistant"
}
]
|
[
{
"content": "How many different countries are all the swimmers from?",
"role": "user"
},
{
"content": "SELECT count(DISTINCT nationality) FROM swimmer",
"role": "assistant"
}
]
|
[
{
"content": "List countries that have more than one swimmer.",
"role": "user"
},
{
"content": "SELECT nationality , count(*) FROM swimmer GROUP BY nationality HAVING count(*) > 1",
"role": "assistant"
}
]
|
[
{
"content": "Find all 200 meter and 300 meter results of swimmers with nationality \"Australia\".",
"role": "user"
},
{
"content": "SELECT meter_200 , meter_300 FROM swimmer WHERE nationality = 'Australia'",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of swimmers who has a result of \"win\".",
"role": "user"
},
{
"content": "SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win'",
"role": "assistant"
}
]
|
[
{
"content": "What is the name of the stadium which held the most events?",
"role": "user"
},
{
"content": "SELECT t1.name FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Find the name and capacity of the stadium where the event named \"World Junior\" happened.",
"role": "user"
},
{
"content": "SELECT t1.name , t1.capacity FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id WHERE t2.name = 'World Junior'",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of stadiums which have never had any event.",
"role": "user"
},
{
"content": "SELECT name FROM stadium WHERE id NOT IN (SELECT stadium_id FROM event)",
"role": "assistant"
}
]
|
[
{
"content": "Find the name of the swimmer who has the most records.",
"role": "user"
},
{
"content": "SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id ORDER BY count(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Find the name of the swimmer who has at least 2 records.",
"role": "user"
},
{
"content": "SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id HAVING count(*) >= 2",
"role": "assistant"
}
]
|
[
{
"content": "Find the name and nationality of the swimmer who has won (i.e., has a result of \"win\") more than 1 time.",
"role": "user"
},
{
"content": "SELECT t1.name , t1.nationality FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' GROUP BY t2.swimmer_id HAVING count(*) > 1",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of the swimmers who have no record.",
"role": "user"
},
{
"content": "SELECT name FROM swimmer WHERE id NOT IN (SELECT swimmer_id FROM record)",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of the swimmers who have both \"win\" and \"loss\" results in the record.",
"role": "user"
},
{
"content": "SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' INTERSECT SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Loss'",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of stadiums that some Australian swimmers have been to.",
"role": "user"
},
{
"content": "SELECT t4.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id JOIN event AS t3 ON t2.event_id = t3.id JOIN stadium AS t4 ON t4.id = t3.stadium_id WHERE t1.nationality = 'Australia'",
"role": "assistant"
}
]
|
[
{
"content": "Find the names of stadiums that the most swimmers have been to.",
"role": "user"
},
{
"content": "SELECT t3.name FROM record AS t1 JOIN event AS t2 ON t1.event_id = t2.id JOIN stadium AS t3 ON t3.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Find all details for each swimmer.",
"role": "user"
},
{
"content": "SELECT * FROM swimmer",
"role": "assistant"
}
]
|
[
{
"content": "What is the average capacity of the stadiums that were opened in year 2005?",
"role": "user"
},
{
"content": "SELECT avg(capacity) FROM stadium WHERE opening_year = 2005",
"role": "assistant"
}
]
|
[
{
"content": "How many railways are there?",
"role": "user"
},
{
"content": "SELECT count(*) FROM railway",
"role": "assistant"
}
]
|
[
{
"content": "List the builders of railways in ascending alphabetical order.",
"role": "user"
},
{
"content": "SELECT Builder FROM railway ORDER BY Builder ASC",
"role": "assistant"
}
]
|
[
{
"content": "List the wheels and locations of the railways.",
"role": "user"
},
{
"content": "SELECT Wheels , LOCATION FROM railway",
"role": "assistant"
}
]
|
[
{
"content": "What is the maximum level of managers in countries that are not \"Australia\"?",
"role": "user"
},
{
"content": "SELECT max(LEVEL) FROM manager WHERE Country != \"Australia\t\"",
"role": "assistant"
}
]
|
[
{
"content": "What is the average age for all managers?",
"role": "user"
},
{
"content": "SELECT avg(Age) FROM manager",
"role": "assistant"
}
]
|
[
{
"content": "What are the names of managers in ascending order of level?",
"role": "user"
},
{
"content": "SELECT Name FROM manager ORDER BY LEVEL ASC",
"role": "assistant"
}
]
|
[
{
"content": "What are the names and arrival times of trains?",
"role": "user"
},
{
"content": "SELECT Name , Arrival FROM train",
"role": "assistant"
}
]
|
[
{
"content": "What is the name of the oldest manager?",
"role": "user"
},
{
"content": "SELECT Name FROM manager ORDER BY Age DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Show the names of trains and locations of railways they are in.",
"role": "user"
},
{
"content": "SELECT T2.Name , T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID",
"role": "assistant"
}
]
|
[
{
"content": "Show the builder of railways associated with the trains named \"Andaman Exp\".",
"role": "user"
},
{
"content": "SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID WHERE T2.Name = \"Andaman Exp\"",
"role": "assistant"
}
]
|
[
{
"content": "Show id and location of railways that are associated with more than one train.",
"role": "user"
},
{
"content": "SELECT T2.Railway_ID , T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*) > 1",
"role": "assistant"
}
]
|
[
{
"content": "Show the id and builder of the railway that are associated with the most trains.",
"role": "user"
},
{
"content": "SELECT T2.Railway_ID , T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Show different builders of railways, along with the corresponding number of railways using each builder.",
"role": "user"
},
{
"content": "SELECT Builder , COUNT(*) FROM railway GROUP BY Builder",
"role": "assistant"
}
]
|
[
{
"content": "Show the most common builder of railways.",
"role": "user"
},
{
"content": "SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Show different locations of railways along with the corresponding number of railways at each location.",
"role": "user"
},
{
"content": "SELECT LOCATION , COUNT(*) FROM railway GROUP BY LOCATION",
"role": "assistant"
}
]
|
[
{
"content": "Show the locations that have more than one railways.",
"role": "user"
},
{
"content": "SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*) > 1",
"role": "assistant"
}
]
|
[
{
"content": "List the object number of railways that do not have any trains.",
"role": "user"
},
{
"content": "SELECT ObjectNumber FROM railway WHERE Railway_ID NOT IN (SELECT Railway_ID FROM train)",
"role": "assistant"
}
]
|
[
{
"content": "Show the countries that have both managers of age above 50 and managers of age below 46.",
"role": "user"
},
{
"content": "SELECT Country FROM manager WHERE Age > 50 INTERSECT SELECT Country FROM manager WHERE Age < 46",
"role": "assistant"
}
]
|
[
{
"content": "Show the distinct countries of managers.",
"role": "user"
},
{
"content": "SELECT DISTINCT Country FROM manager",
"role": "assistant"
}
]
|
[
{
"content": "Show the working years of managers in descending order of their level.",
"role": "user"
},
{
"content": "SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC",
"role": "assistant"
}
]
|
[
{
"content": "Show the countries that have managers of age above 50 or below 46.",
"role": "user"
},
{
"content": "SELECT Country FROM manager WHERE Age > 50 OR Age < 46",
"role": "assistant"
}
]
|
[
{
"content": "How many addresses are there in country USA?",
"role": "user"
},
{
"content": "SELECT count(*) FROM addresses WHERE country = 'USA'",
"role": "assistant"
}
]
|
[
{
"content": "Show all distinct cities in the address record.",
"role": "user"
},
{
"content": "SELECT DISTINCT city FROM addresses",
"role": "assistant"
}
]
|
[
{
"content": "Show each state and the number of addresses in each state.",
"role": "user"
},
{
"content": "SELECT state_province_county , count(*) FROM addresses GROUP BY state_province_county",
"role": "assistant"
}
]
|
[
{
"content": "Show names and phones of customers who do not have address information.",
"role": "user"
},
{
"content": "SELECT customer_name , customer_phone FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history)",
"role": "assistant"
}
]
|
[
{
"content": "Show the name of the customer who has the most orders.",
"role": "user"
},
{
"content": "SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Show the product type codes which have at least two products.",
"role": "user"
},
{
"content": "SELECT product_type_code FROM products GROUP BY product_type_code HAVING count(*) >= 2",
"role": "assistant"
}
]
|
[
{
"content": "Show the names of customers who have both an order in completed status and an order in part status.",
"role": "user"
},
{
"content": "SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Part'",
"role": "assistant"
}
]
|
[
{
"content": "Show the name, phone, and payment method code for all customers in descending order of customer number.",
"role": "user"
},
{
"content": "SELECT customer_name , customer_phone , payment_method_code FROM customers ORDER BY customer_number DESC",
"role": "assistant"
}
]
|
[
{
"content": "Show the product name and total order quantity for each product.",
"role": "user"
},
{
"content": "SELECT T1.product_name , sum(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_id",
"role": "assistant"
}
]
|
[
{
"content": "Show the minimum, maximum, average price for all products.",
"role": "user"
},
{
"content": "SELECT min(product_price) , max(product_price) , avg(product_price) FROM products",
"role": "assistant"
}
]
|
[
{
"content": "How many products have a price higher than the average?",
"role": "user"
},
{
"content": "SELECT count(*) FROM products WHERE product_price > (SELECT avg(product_price) FROM products)",
"role": "assistant"
}
]
|
[
{
"content": "Show the customer name, customer address city, date from, and date to for each customer address history.",
"role": "user"
},
{
"content": "SELECT T2.customer_name , T3.city , T1.date_from , T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id JOIN addresses AS T3 ON T1.address_id = T3.address_id",
"role": "assistant"
}
]
|
[
{
"content": "Show the names of customers who use Credit Card payment method and have more than 2 orders.",
"role": "user"
},
{
"content": "SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.payment_method_code = 'Credit Card' GROUP BY T1.customer_id HAVING count(*) > 2",
"role": "assistant"
}
]
|
[
{
"content": "What are the name and phone of the customer with the most ordered product quantity?",
"role": "user"
},
{
"content": "SELECT T1.customer_name , T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T3.order_id = T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC LIMIT 1",
"role": "assistant"
}
]
|
[
{
"content": "Show the product type and name for the products with price higher than 1000 or lower than 500.",
"role": "user"
},
{
"content": "SELECT product_type_code , product_name FROM products WHERE product_price > 1000 OR product_price < 500",
"role": "assistant"
}
]
|
[
{
"content": "Find the name of dorms only for female (F gender).",
"role": "user"
},
{
"content": "SELECT dorm_name FROM dorm WHERE gender = 'F'",
"role": "assistant"
}
]
|
[
{
"content": "What are the names of the all-female dorms?",
"role": "user"
},
{
"content": "SELECT dorm_name FROM dorm WHERE gender = 'F'",
"role": "assistant"
}
]
|
[
{
"content": "Find the name of dorms that can accommodate more than 300 students.",
"role": "user"
},
{
"content": "SELECT dorm_name FROM dorm WHERE student_capacity > 300",
"role": "assistant"
}
]
|
[
{
"content": "What are the names of all the dorms that can accomdate more than 300 students?",
"role": "user"
},
{
"content": "SELECT dorm_name FROM dorm WHERE student_capacity > 300",
"role": "assistant"
}
]
|
[
{
"content": "How many female students (sex is F) whose age is below 25?",
"role": "user"
},
{
"content": "SELECT count(*) FROM student WHERE sex = 'F' AND age < 25",
"role": "assistant"
}
]
|
[
{
"content": "How many girl students who are younger than 25?",
"role": "user"
},
{
"content": "SELECT count(*) FROM student WHERE sex = 'F' AND age < 25",
"role": "assistant"
}
]
|
[
{
"content": "Find the first name of students who is older than 20.",
"role": "user"
},
{
"content": "SELECT fname FROM student WHERE age > 20",
"role": "assistant"
}
]
|
[
{
"content": "What are the first names of all students who are older than 20?",
"role": "user"
},
{
"content": "SELECT fname FROM student WHERE age > 20",
"role": "assistant"
}
]
|
[
{
"content": "Find the first name of students living in city PHL whose age is between 20 and 25.",
"role": "user"
},
{
"content": "SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25",
"role": "assistant"
}
]
|
[
{
"content": "What is the first name of the students who are in age 20 to 25 and living in PHL city?",
"role": "user"
},
{
"content": "SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25",
"role": "assistant"
}
]
|
[
{
"content": "How many dorms are there?",
"role": "user"
},
{
"content": "SELECT count(*) FROM dorm",
"role": "assistant"
}
]
|
[
{
"content": "How many dorms are in the database?",
"role": "user"
},
{
"content": "SELECT count(*) FROM dorm",
"role": "assistant"
}
]
|
[
{
"content": "Find the number of distinct amenities.",
"role": "user"
},
{
"content": "SELECT count(*) FROM dorm_amenity",
"role": "assistant"
}
]
|
[
{
"content": "How many diffrent dorm amenities are there?",
"role": "user"
},
{
"content": "SELECT count(*) FROM dorm_amenity",
"role": "assistant"
}
]
|
[
{
"content": "Find the total capacity of all dorms.",
"role": "user"
},
{
"content": "SELECT sum(student_capacity) FROM dorm",
"role": "assistant"
}
]
|
[
{
"content": "What is the total student capacity of all dorms?",
"role": "user"
},
{
"content": "SELECT sum(student_capacity) FROM dorm",
"role": "assistant"
}
]
|
[
{
"content": "How many students are there?",
"role": "user"
},
{
"content": "SELECT count(*) FROM student",
"role": "assistant"
}
]
|
[
{
"content": "How many students exist?",
"role": "user"
},
{
"content": "SELECT count(*) FROM student",
"role": "assistant"
}
]
|
[
{
"content": "Find the average age of all students living in the each city.",
"role": "user"
},
{
"content": "SELECT avg(age) , city_code FROM student GROUP BY city_code",
"role": "assistant"
}
]
|
[
{
"content": "What is the average age for each city and what are those cities?",
"role": "user"
},
{
"content": "SELECT avg(age) , city_code FROM student GROUP BY city_code",
"role": "assistant"
}
]
|
[
{
"content": "Find the average and total capacity of dorms for the students with gender X.",
"role": "user"
},
{
"content": "SELECT avg(student_capacity) , sum(student_capacity) FROM dorm WHERE gender = 'X'",
"role": "assistant"
}
]
|
[
{
"content": "What is the average and total capacity for all dorms who are of gender X?",
"role": "user"
},
{
"content": "SELECT avg(student_capacity) , sum(student_capacity) FROM dorm WHERE gender = 'X'",
"role": "assistant"
}
]
|
[
{
"content": "Find the number of dorms that have some amenity.",
"role": "user"
},
{
"content": "SELECT count(DISTINCT dormid) FROM has_amenity",
"role": "assistant"
}
]
|
[
{
"content": "How many dorms have amenities?",
"role": "user"
},
{
"content": "SELECT count(DISTINCT dormid) FROM has_amenity",
"role": "assistant"
}
]
|
[
{
"content": "Find the name of dorms that do not have any amenity",
"role": "user"
},
{
"content": "SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity)",
"role": "assistant"
}
]
|
[
{
"content": "What are the names of all the dorms that don't have any amenities?",
"role": "user"
},
{
"content": "SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity)",
"role": "assistant"
}
]
|
[
{
"content": "Find the number of distinct gender for dorms.",
"role": "user"
},
{
"content": "SELECT count(DISTINCT gender) FROM dorm",
"role": "assistant"
}
]
|
[
{
"content": "How many different genders are there in the dorms?",
"role": "user"
},
{
"content": "SELECT count(DISTINCT gender) FROM dorm",
"role": "assistant"
}
]
|
[
{
"content": "Find the capacity and gender type of the dorm whose name has substring ‘Donor’.",
"role": "user"
},
{
"content": "SELECT student_capacity , gender FROM dorm WHERE dorm_name LIKE '%Donor%'",
"role": "assistant"
}
]
|
[
{
"content": "What is the student capacity and type of gender for the dorm whose name as the phrase Donor in it?",
"role": "user"
},
{
"content": "SELECT student_capacity , gender FROM dorm WHERE dorm_name LIKE '%Donor%'",
"role": "assistant"
}
]
|
[
{
"content": "Find the name and gender type of the dorms whose capacity is greater than 300 or less than 100.",
"role": "user"
},
{
"content": "SELECT dorm_name , gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100",
"role": "assistant"
}
]
|
[
{
"content": "What are the names and types of the dorms that have a capacity greater than 300 or less than 100?",
"role": "user"
},
{
"content": "SELECT dorm_name , gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100",
"role": "assistant"
}
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.