anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
List all role codes, role names, and role descriptions. | SELECT role_code , role_name , role_description FROM ROLES |
Find the names of all reviewers who have contributed three or more ratings. | SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T1.rID HAVING COUNT(*) >= 3 |
display the ID for those employees who did two or more jobs in the past. | SELECT employee_id FROM job_history GROUP BY employee_id HAVING COUNT(*) >= 2 |
For each party, find its location and the name of its host. Sort the result in ascending order of the age of the host. | SELECT T3.Location , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID ORDER BY T2.Age |
How many papers are published by the institution "Tokohu University"? | SELECT count(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Tokohu University" |
Which address has both members younger than 30 and members older than 40? | SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40 |
What are the distinct name, location and products of the enzymes which has any 'inhibitor' interaction? | SELECT DISTINCT T1.name , T1.location , T1.product FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.enzyme_id = T1.id WHERE T2.interaction_type = 'inhibitor' |
What is the average song duration for the songs that are in mp3 format and whose resolution below 800? | SELECT avg(T1.duration) FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.formats = "mp3" AND T2.resolution < 800 |
How many times in total did the team Boston Red Stockings participate in postseason games? | SELECT count(*) FROM ( SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' UNION SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' ); |
What are the names and urls of images, sorted alphabetically? | SELECT image_name , image_url FROM images ORDER BY image_name |
List the name of the pilots who have flied for both a company that mainly provide 'Cargo' services and a company that runs 'Catering services' activities. | SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T1.principal_activities = 'Cargo' INTERSECT SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T1.principal_activities = 'Catering services' |
What are the song titles on the album "A Kiss Before You Go: Live in Hamburg"? | SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE T1.title = "A Kiss Before You Go: Live in Hamburg" |
Find the name of the person who has no student friends. | SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.job = 'student' |
Which vocal type did the musician with first name "Solveig" played in the song with title "A Bar in Amsterdam"? | SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid JOIN band AS T3 ON T1.bandmate = T3.id WHERE T3.firstname = "Solveig" AND T2.title = "A Bar In Amsterdam" |
What is the total amount of grant money for research? | SELECT sum(grant_amount) FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id = T2.organisation_id JOIN organisation_Types AS T3 ON T2.organisation_type = T3.organisation_type WHERE T3.organisation_type_description = 'Research' |
Show the prices of publications whose publisher is either "Person" or "Wiley" | SELECT Price FROM publication WHERE Publisher = "Person" OR Publisher = "Wiley" |
Show the denomination of the school that has the most players. | SELECT T2.Denomination FROM player AS T1 JOIN school AS T2 ON T1.School_ID = T2.School_ID GROUP BY T1.School_ID ORDER BY COUNT(*) DESC LIMIT 1 |
What is the description of the club "Pen and Paper Gaming"? | SELECT clubdesc FROM club WHERE clubname = "Pen and Paper Gaming" |
Find the first name of students living in city PHL whose age is between 20 and 25. | SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25 |
What is the description of document type 'Paper'? | SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper"; |
Which bike traveled the most often in zip code 94002? | SELECT bike_id FROM trip WHERE zip_code = 94002 GROUP BY bike_id ORDER BY COUNT(*) DESC LIMIT 1 |
What are the names, color descriptions, and product descriptions for products in the 'Herbs' category? | SELECT T1.product_name , T2.color_description , T1.product_description FROM products AS T1 JOIN Ref_colors AS T2 ON T1.color_code = T2.color_code WHERE product_category_code = "Herbs" |
What is the sum of total pounds of purchase in year 2018 for all branches in London? | SELECT sum(total_pounds) FROM purchase AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T2.city = 'London' AND T1.year = 2018 |
Return the hispanic percentage for cities in which the black percentage is greater than 10. | SELECT Hispanic FROM city WHERE Black > 10 |
Find the average age of all students living in the each city. | SELECT avg(age) , city_code FROM student GROUP BY city_code |
Find the country of all appelations who have at most three wines. | SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING count(*) <= 3 |
What are the highest and lowest prices of products, grouped by and alphabetically ordered by product type? | SELECT max(product_price) , min(product_price) , product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code |
Sort all the industries in descending order of the count of companies in each industry | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC |
What are the order ids and customer ids for orders that have been Cancelled, sorted by their order dates? | SELECT order_id , customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date |
Return the descriptions and names of the courses that have more than two students enrolled in. | SELECT T1.course_description , T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) > 2 |
How many members are not living in Hartford? | SELECT count(*) FROM member WHERE address != 'Hartford' |
Give me a list of id and status of orders which belong to the customer named "Jeramie". | SELECT T2.order_id , T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie" |
How many problems does the product with the most problems have? List the number of the problems and product name. | SELECT count(*) , T1.product_name FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_name ORDER BY count(*) DESC LIMIT 1 |
List the forenames of all distinct drivers in alphabetical order? | SELECT DISTINCT forename FROM drivers ORDER BY forename ASC |
What is the code of the school where the accounting department belongs to? | SELECT school_code FROM department WHERE dept_name = "Accounting" |
Return the number of accounts that the customer with the first name Art and last name Turcotte has. | SELECT count(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte" |
What are the ids and details for each project? | SELECT project_id , project_details FROM Projects |
What are the names of body builders whose total score is higher than 300? | SELECT T2.Name FROM body_builder AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Total > 300 |
List the full name (first and last name), and salary for those employees who earn below 6000. | SELECT first_name , last_name , salary FROM employees WHERE salary < 6000 |
What is the id of the reviewer whose name includes the word "Mike"? | SELECT rID FROM Reviewer WHERE name LIKE "%Mike%" |
What are the bed type and name of all the rooms with traditional decor? | SELECT roomName , bedType FROM Rooms WHERE decor = "traditional"; |
What are the first and last names of all customers with more than 2 payments? | SELECT T2.first_name , T2.last_name FROM Customer_Payments AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) > 2; |
What are the names of the stations which serve both "Ananthapuri Express" and "Guruvayur Express" trains? | SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T3.Name = "Ananthapuri Express" INTERSECT SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id =... |
Please show the employee first names and ids of employees who serve at least 10 customers. | SELECT T1.FirstName , T1.SupportRepId FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) >= 10 |
Find the city where the most customers live. | SELECT t3.city FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id GROUP BY t3.city ORDER BY count(*) DESC LIMIT 1 |
What are the ids of every student who has never attended a course? | SELECT student_id FROM students WHERE student_id NOT IN (SELECT student_id FROM student_course_attendance) |
Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order of year. | SELECT DISTINCT YEAR FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year |
Find the ids and names of members who are under age 30 or with black membership card. | SELECT name , member_id FROM member WHERE Membership_card = 'Black' OR age < 30 |
What is the aircraft name for the flight with number 99 | SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99 |
What are the different regions of clubs in ascending alphabetical order? | SELECT DISTINCT Region FROM club ORDER BY Region ASC |
Which cities have 2 to 4 parks? | SELECT city FROM park GROUP BY city HAVING count(*) BETWEEN 2 AND 4; |
Give the distinct famous release dates for all artists. | SELECT distinct(Famous_Release_date) FROM artist |
What is the id of the instructor who advises of all students from History department? | SELECT i_id FROM advisor AS T1 JOIN student AS T2 ON T1.s_id = T2.id WHERE T2.dept_name = 'History' |
For each classroom, report the classroom number and the number of grades using it. | SELECT classroom , count(DISTINCT grade) FROM list GROUP BY classroom |
Show all distinct city where branches with at least 100 memberships are located. | SELECT DISTINCT city FROM branch WHERE membership_amount >= 100 |
What are the distinct details of invoices created before 1989-09-03 or after 2007-12-25? | SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25" |
What are the names of the storms that affected Denmark? | SELECT T3.name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T2.region_name = 'Denmark' |
What is the count of cities with more than 3 airports? | SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3) |
List the customers first and last name of 10 least expensive invoices. | SELECT T1.first_name , T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY total LIMIT 10; |
How many faculty members does each building have? List the result with the name of the building. | SELECT building , count(*) FROM Faculty GROUP BY building |
Which apartments have bookings with both status codes "Provisional" and "Confirmed"? Give me the apartment numbers. | SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = "Confirmed" INTERSECT SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = "Provisional" |
Find the name and salary of the instructors who are advisors of any student from History department? | SELECT T2.name , T2.salary FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'History' |
Find the city with post code 255. | SELECT city FROM addresses WHERE zip_postcode = 255 |
What are the cities that have a branch that opened in 2001 and a branch with more than 100 members? | SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100 |
List every individual's first name, middle name and last name in alphabetical order by last name. | SELECT individual_first_name , individual_middle_name , individual_last_name FROM individuals ORDER BY individual_last_name |
What are the campuses that had between 600 and 1000 faculty members in 2004? | SELECT T1.campus FROM campuses AS t1 JOIN faculty AS t2 ON t1.id = t2.campus WHERE t2.faculty >= 600 AND t2.faculty <= 1000 AND T1.year = 2004 |
What are all the labels? | SELECT DISTINCT label FROM Albums |
How many users are there? | SELECT count(*) FROM user_profiles |
List the names, phone numbers, and emails of all customers sorted by their dates of becoming customers. | SELECT customer_name , customer_phone , customer_email FROM Customers ORDER BY date_became_customer |
List phone number and email address of customer with more than 2000 outstanding balance. | SELECT phone_number , email_address FROM Customers WHERE amount_outstanding > 2000; |
What campuses are in Los Angeles county? | SELECT campus FROM campuses WHERE county = "Los Angeles" |
How many lessons were taught by a staff member whose first name has the letter 'a' in it? | SELECT count(*) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name LIKE "%a%" |
Return the names of shops, ordered by year of opening ascending. | SELECT Shop_Name FROM shop ORDER BY Open_Year ASC |
How many different scientists are assigned to any project? | SELECT count(DISTINCT scientist) FROM assignedto |
What are the codes corresponding to document types for which there are less than 3 documents? | SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*) < 3 |
What are the names of storms that did not affect any regions? | SELECT name FROM storm WHERE storm_id NOT IN (SELECT storm_id FROM affected_region) |
What are the three colleges from which the most players are from? | SELECT College FROM match_season GROUP BY College ORDER BY count(*) DESC LIMIT 3 |
How many people are older than every engineer? | SELECT count(*) FROM Person WHERE age > (SELECT max(age) FROM person WHERE job = 'engineer') |
Show the result of the submission with the highest score. | SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1 |
List the names of buildings in descending order of building height. | SELECT name FROM buildings ORDER BY Height DESC |
What is the name of the patient who made the most recent appointment? | SELECT T1.name FROM patient AS T1 JOIN appointment AS T2 ON T1.ssn = T2.patient ORDER BY T2.start DESC LIMIT 1 |
Find the name of amenities Smith Hall dorm have. | SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall' |
List the industry shared by the most companies. | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 |
Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds? | SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000 |
Find the payment method that is used the most often in all the invoices. Give me its code. | SELECT payment_method_code FROM INVOICES GROUP BY payment_method_code ORDER BY count(*) DESC LIMIT 1 |
What are the employee ids of employees who report to Payam, and what are their salaries? | SELECT employee_id , salary FROM employees WHERE manager_id = (SELECT employee_id FROM employees WHERE first_name = 'Payam' ) |
What are the average fastest lap speed in races held after 2004 grouped by race name and ordered by year? | SELECT avg(T2.fastestlapspeed) , T1.name , T1.year FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year > 2014 GROUP BY T1.name ORDER BY T1.year |
Find the names of customers whose name contains "Diana". | SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%" |
Show all director names who have a movie in both year 1999 and 2000. | SELECT director FROM movie WHERE YEAR = 2000 INTERSECT SELECT director FROM movie WHERE YEAR = 1999 |
For each end station id, what is its name, latitude, and minimum duration for trips ended there? | SELECT T1.name , T1.lat , min(T2.duration) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.end_station_id GROUP BY T2.end_station_id |
What is the code of the product type with an average price higher than the average price of all products? | SELECT product_type_code FROM products GROUP BY product_type_code HAVING avg(product_price) > (SELECT avg(product_price) FROM products) |
Find all the films longer than 100 minutes, or rated PG, except those who cost more than 200 for replacement. List the titles. | SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200 |
What is the id of the product that is booked for 3 times? | SELECT product_id FROM products_booked GROUP BY product_id HAVING count(*) = 3 |
Find the name of the airport in the city of Goroka. | SELECT name FROM airports WHERE city = 'Goroka' |
Which poll resource provided the most number of candidate information? | SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY count(*) DESC LIMIT 1 |
Show all card type codes and the number of cards in each type. | SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code |
Find the names of the tourist attractions that is either accessible by walk or at address 660 Shea Crescent. | SELECT T2.Name FROM Locations AS T1 JOIN Tourist_Attractions AS T2 ON T1.Location_ID = T2.Location_ID WHERE T1.Address = "660 Shea Crescent" OR T2.How_to_Get_There = "walk" |
Who performed the song named "Le Pop"? | SELECT T2.firstname , T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Le Pop" |
Show the census ranking of cities whose status are not "Village". | SELECT Census_Ranking FROM city WHERE Status != "Village" |
How many students received a yes from tryouts? | SELECT count(*) FROM tryout WHERE decision = 'yes' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.