anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
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 |
How many games were played in park "Columbia Park" in 1907? | SELECT count(*) FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 1907 AND T2.park_name = 'Columbia Park'; |
List the name and residence for players whose occupation is not "Researcher". | SELECT Player_name , residence FROM player WHERE Occupation != "Researcher" |
How old is each gender, on average? | SELECT avg(age) , gender FROM Person GROUP BY gender |
What are the number of rooms for each bed type? | SELECT bedType , count(*) FROM Rooms GROUP BY bedType; |
What are the name and id of the team with the most victories in 2008 postseason? | SELECT T2.name , T1.team_id_winner FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T1.year = 2008 GROUP BY T1.team_id_winner ORDER BY count(*) DESC LIMIT 1; |
What are the dates of the assessment notes? | SELECT date_of_notes FROM Assessment_Notes |
What are the distinct names of customers who have purchased at least three different products? | SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id GROUP BY T1.customer_id HAVING COUNT (DISTINCT T3.product_id) >= 3 |
Find the number of teachers who teach the student called CHRISSY NABOZNY. | SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.firstname = "CHRISSY" AND T1.lastname = "NABOZNY" |
Find the first names of professors who are teaching more than one class. | SELECT T2.emp_fname FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num GROUP BY T1.prof_num HAVING count(*) > 1 |
What are the employee ids of the employees whose role name is "Human Resource" or "Manager"? | SELECT T1.employee_id FROM Employees AS T1 JOIN ROLES AS T2 ON T1.role_code = T2.role_code WHERE T2.role_name = "Human Resource" OR T2.role_name = "Manager" |
How many book clubs are there? | SELECT count(*) FROM book_club |
Show the season, the player, and the name of the team that players belong to. | SELECT T1.Season , T1.Player , T2.Name FROM match_season AS T1 JOIN team AS T2 ON T1.Team = T2.Team_id |
What are the names of all cities and states? | SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses |
How many markets have number of cities smaller than 300? | SELECT count(*) FROM market WHERE Number_cities < 300 |
In which country and state does Janessa Sawayn live? | SELECT T1.country , T1.state_province_county FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"; |
Give me the name and description of the location with code x. | SELECT location_name , location_description FROM Ref_locations WHERE location_code = "x" |
What are the first names and last names of all the guests? | SELECT guest_first_name , guest_last_name FROM Guests |
Find the id of the customers who have order status both "On Road" and "Shipped". | SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped" |
What are the details of all products? | SELECT DISTINCT product_details FROM products |
Find the name and college of students whose decisions are yes in the tryout. | SELECT T1.pName , T2.cName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' |
What is the average number of stars that each reviewer awards for a movie? | SELECT T2.name , avg(T1.stars) FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T2.name |
Show the delegate from district 1 in election. | SELECT Delegate FROM election WHERE District = 1 |
Find the name of all the cities and states. | SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses |
Find the titles of items that received both a rating higher than 8 and a rating below 5. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > 8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5 |
What are the countries that contain 3 or more cities? | SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id GROUP BY T2.country_id HAVING count(*) >= 3 |
What are the ids and details of all accounts? | SELECT account_id , account_details FROM Accounts |
Show the name and date for each race and its track name. | SELECT T1.name , T1.date , T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id |
Find the max, average and min training hours of all players. | SELECT avg(HS) , max(HS) , min(HS) FROM Player |
Find the Char cells, Pixels and Hardware colours for the screen of the phone whose hardware model name is "LG-P760". | SELECT T1.Char_cells , T1.Pixels , T1.Hardware_colours FROM screen_mode AS T1 JOIN phone AS T2 ON T1.Graphics_mode = T2.screen_mode WHERE T2.Hardware_Model_name = "LG-P760"; |
What is maximum group equity shareholding of the companies? | SELECT max(group_equity_shareholding) FROM operate_company |
Show name, address road, and city for all branches sorted by open year. | SELECT name , address_road , city FROM branch ORDER BY open_year |
What is the average weeks on top of volumes associated with the artist aged 25 or younger? | SELECT avg(T2.Weeks_on_Top) FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 25 |
How many events did not have any participants? | SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events) |
Find the name of dorms only for female (F gender). | SELECT dorm_name FROM dorm WHERE gender = 'F' |
How many sections does each course have? | SELECT count(*) , crs_code FROM CLASS GROUP BY crs_code |
What is the id for the employee called Ebba? | SELECT employee_ID FROM Employees WHERE employee_name = "Ebba" |
Find out the first name and last name of staff lived in city Damianfort. | SELECT T2.first_name , T2.last_name FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id WHERE T1.city = "Damianfort"; |
How many players are there? | SELECT count(*) FROM player |
Which months have more than 2 happy hours? | SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING count(*) > 2 |
What are the names of all the different reviewers who rates Gone with the Wind? | SELECT DISTINCT T3.name FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.title = 'Gone with the Wind' |
Find the name of the dorm with the largest capacity. | SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1 |
What are the official names of cities, ordered descending by population? | SELECT Official_Name FROM city ORDER BY Population DESC |
What are the employee ids and job ids for employees who make less than the lowest earning employee with title MK_MAN? | SELECT employee_id , job_id FROM employees WHERE salary < ( SELECT min(salary) FROM employees WHERE job_id = 'MK_MAN' ) |
Which services have been used more than twice in first notification of loss? Return the service name. | SELECT t2.service_name FROM first_notification_of_loss AS t1 JOIN services AS t2 ON t1.service_id = t2.service_id GROUP BY t1.service_id HAVING count(*) > 2 |
Count the number of companies. | SELECT count(*) FROM Companies |
Which problems were reported by the staff named Dameon Frami or Jolie Weber? Give me the ids of the problems. | SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Dameon" AND T2.staff_last_name = "Frami" UNION SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Jolie" AND T2.staff_las... |
Find the the names of the tourist attractions that the tourist named Alison visited but Rosalind did not visit. | SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_Attraction_ID = T3.Tourist_Attraction_ID AND T2.Tourist_ID = T3.Tourist_ID WHERE T2.Tourist_Details = "Alison" EXCEPT SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_... |
Return the rank for which there are the fewest captains. | SELECT rank FROM captain GROUP BY rank ORDER BY count(*) DESC LIMIT 1 |
Find the name and budget of departments whose budgets are more than the average budget. | SELECT dept_name , budget FROM department WHERE budget > (SELECT avg(budget) FROM department) |
How many customers have no payment histories? | SELECT count(*) FROM Customers WHERE customer_id NOT IN ( SELECT customer_id FROM Customer_Payments ); |
What are the different transaction types, and how many transactions of each have taken place? | SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type |
Find the detail of products whose detail contains the word "Latte" or the word "Americano" | SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%" |
What are the dates and locations of performances? | SELECT Date , LOCATION FROM performance |
What is title of album which track Balls to the Wall belongs to? | SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall"; |
How many rooms in total are there in the apartments in the building with short name "Columbus Square"? | SELECT sum(T2.room_count) FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id = T2.building_id WHERE T1.building_short_name = "Columbus Square" |
Find the zip code in which the average mean visibility is lower than 10. | SELECT zip_code FROM weather GROUP BY zip_code HAVING avg(mean_visibility_miles) < 10 |
List the names of products that are not in any event. | SELECT Product_Name FROM Products WHERE Product_ID NOT IN (SELECT Product_ID FROM Products_in_Events) |
Find the number of students who participate in the tryout for each college ordered by descending count. | SELECT count(*) , cName FROM tryout GROUP BY cName ORDER BY count(*) DESC |
What are the 3 most common cloud covers in the zip code of 94107? | SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT (*) DESC LIMIT 3 |
What is all the information regarding employees with salaries above the minimum and under 2500? | SELECT * FROM employees WHERE salary BETWEEN (SELECT MIN(salary) FROM employees) AND 2500 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.