anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
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' |
Show all train names and times in stations in London in descending order by train time. | SELECT T3.name , T3.time 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 T2.location = 'London' ORDER BY T3.time DESC |
What are the result description of the project whose detail is 'sint'? | SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code JOIN Projects AS T3 ON T2.project_id = T3.project_id WHERE T3.project_details = 'sint' |
Which employees do not authorize destruction for any document? Give me their employee ids. | SELECT employee_id FROM Employees EXCEPT SELECT Destruction_Authorised_by_Employee_ID FROM Documents_to_be_destroyed |
What are the names of the albums that have more than 10 tracks? | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.album_id GROUP BY T1.id HAVING count(T1.id) > 10; |
List the name and the number of enrolled student for each course. | SELECT T1.course_name , COUNT(*) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name |
Find the names of reviewers who had given higher than 3 star ratings. | SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3 |
What are the names of the courses in alphabetical order? | SELECT course_name FROM courses ORDER BY course_name |
What are the names of the stations that are located in Palo Alto but have never been the ending point of the trips | SELECT name FROM station WHERE city = "Palo Alto" EXCEPT SELECT end_station_name FROM trip GROUP BY end_station_name HAVING count(*) > 100 |
What is the average age and how many male students are there in each city? | SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code |
Find the details of the shops that can be reached by walk. | SELECT T1.Shop_Details FROM SHOPS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Shop_ID = T2.Tourist_Attraction_ID WHERE T2.How_to_Get_There = "walk" |
Find the patient who has the most recent undergoing treatment? | SELECT patient FROM undergoes ORDER BY dateundergoes LIMIT 1 |
List the names of all scientists sorted in alphabetical order. | SELECT name FROM scientists ORDER BY name |
What are the personal names used both by some course authors and some students? | SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students |
Find the student ID and login name of the student with the most course enrollments | SELECT T1.student_id , T2.login_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1 |
Find the first names and degree of all professors who are teaching some class in Computer Info. Systems department. | SELECT DISTINCT T2.emp_fname , T3.prof_high_degree FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN professor AS T3 ON T2.emp_num = T3.emp_num JOIN department AS T4 ON T4.dept_code = T3.dept_code WHERE T4.dept_name = 'Computer Info. Systems' |
What are the names of all the circuits that are in the UK or Malaysia? | SELECT name FROM circuits WHERE country = "UK" OR country = "Malaysia" |
What is the name of the country with the most number of home airlines? | SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1 |
Show the first name, last name, and phone number for all female faculty members. | SELECT Fname , Lname , phone FROM Faculty WHERE Sex = 'F' |
What are the birthdays of people in ascending order of height? | SELECT Birth_Date FROM People ORDER BY Height ASC |
Find the phone numbers of customers using the most common policy type among the available policies. | SELECT customer_phone FROM available_policies WHERE policy_type_code = (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1) |
What are the dates of ceremony at music festivals corresponding to volumes that lasted more than 2 weeks on top? | SELECT T1.Date_of_ceremony FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T2.Weeks_on_Top > 2 |
How many schools have some students playing in goalie and mid positions. | SELECT COUNT(*) FROM (SELECT cName FROM tryout WHERE pPos = 'goalie' INTERSECT SELECT cName FROM tryout WHERE pPos = 'mid') |
How many different cities do have some airport in the country of Greenland? | SELECT count(DISTINCT city) FROM airports WHERE country = 'Greenland' |
Give the name of the student in the History department with the most credits. | SELECT name FROM student WHERE dept_name = 'History' ORDER BY tot_cred DESC LIMIT 1 |
Return the number of companies created by Andy. | SELECT count(*) FROM manufacturers WHERE founder = 'Andy' |
What is the minimum and maximum number of bathrooms of all the apartments? | SELECT min(bathroom_count) , max(bathroom_count) FROM Apartments |
List the studios of each film and the number of films produced by that studio. | SELECT Studio , COUNT(*) FROM film GROUP BY Studio |
Find the names of all procedures which cost more than 1000 but which physician John Wen was not trained in? | SELECT name FROM procedures WHERE cost > 1000 EXCEPT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen" |
display the department name and number of employees in each of the department. | SELECT department_name , COUNT(*) FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id GROUP BY department_name |
What campuses opened before 1800? | SELECT campus FROM campuses WHERE YEAR < 1800 |
What is the name of the institution the author "Katsuhiro Ueno" belongs to? | SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = "Katsuhiro" AND t1.lname = "Ueno" |
What is the average bike availablility for stations not in Palo Alto? | SELECT avg(bikes_available) FROM status WHERE station_id NOT IN (SELECT id FROM station WHERE city = "Palo Alto") |
Who are the players that have names containing the letter a? | SELECT DISTINCT pName FROM Player WHERE pName LIKE '%a%' |
What is the season of the game which causes the player 'Walter Samuel' to get injured? | SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id = T2.game_id WHERE T2.player = 'Walter Samuel' |
How many characteristics does the product named "laurel" have? | SELECT count(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "laurel" |
Show the price ranges of hotels with 5 star ratings. | SELECT price_range FROM HOTELS WHERE star_rating_code = "5" |
How many courses are there in total? | SELECT count(*) FROM COURSES |
Find the category descriptions of the products whose descriptions include letter 't'. | SELECT T1.product_category_description FROM ref_product_categories AS T1 JOIN products AS T2 ON T1.product_category_code = T2.product_category_code WHERE T2.product_description LIKE '%t%' |
What is the name of each aircraft and how many flights does each one complete? | SELECT T2.name , count(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid |
What are the mission codes, fates, and names of the ships involved? | SELECT T1.Code , T1.Fate , T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.