anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
What is the headquarter of the company with the largest sales? | SELECT Headquarters FROM company ORDER BY Sales_in_Billion DESC LIMIT 1 |
Return the average, minimum, maximum, and total transaction amounts. | SELECT avg(transaction_amount) , min(transaction_amount) , max(transaction_amount) , sum(transaction_amount) FROM Financial_transactions |
What is all the information regarding employees who are managers? | SELECT DISTINCT * FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id WHERE T1.employee_id = T2.manager_id |
How many professors attained either Ph.D. or Masters degrees? | SELECT count(*) FROM professor WHERE prof_high_degree = 'Ph.D.' OR prof_high_degree = 'MA' |
Please list the countries and years of film market estimations. | SELECT T2.Country , T1.Year FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID |
How many students got accepted after the tryout? | SELECT count(*) FROM tryout WHERE decision = 'yes' |
What is the average age for each gender? | SELECT avg(age) , gender FROM Person GROUP BY gender |
Find the last names of students studying in room 111. | SELECT lastname FROM list WHERE classroom = 111 |
How many churches opened before 1850 are there? | SELECT count(*) FROM Church WHERE Open_Date < 1850 |
What are the full names of all students | SELECT Fname , Lname FROM Student |
What is the department name of the students with lowest gpa belongs to? | SELECT T2.dept_name FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code ORDER BY stu_gpa LIMIT 1 |
Show the average amount of transactions with type code "SALE". | SELECT avg(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" |
Who is the oldest person? | SELECT name FROM Person WHERE age = (SELECT max(age) FROM person) |
Find the maximum and minimum settlement amount. | SELECT max(settlement_amount) , min(settlement_amount) FROM settlements |
Who are the owners of the programs that broadcast both in the morning and at night? | SELECT t1.owner FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Morning" INTERSECT SELECT t1.owner FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Night" |
Find the name, address, number of students in the departments that have the top 3 highest number of students. | SELECT T2.dept_name , T2.dept_address , count(*) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) DESC LIMIT 3 |
Tell me the highest, lowest, and average cost of procedures. | SELECT MAX(cost) , MIN(cost) , AVG(cost) FROM procedures |
Which song has the most vocals? | SELECT title FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid GROUP BY T1.songid ORDER BY count(*) DESC LIMIT 1 |
Find the total number of instructors who teach a course in the Spring 2010 semester. | SELECT COUNT (DISTINCT ID) FROM teaches WHERE semester = 'Spring' AND YEAR = 2010 |
Give the neames of wines with prices below 50 and with appelations in Monterey county. | SELECT T2.Name FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = "Monterey" AND T2.price < 50 |
Return the phone and email of the customer with the first name Aniyah and last name Feest. | SELECT customer_phone , customer_email FROM Customers WHERE customer_first_name = "Aniyah" AND customer_last_name = "Feest" |
How many customers are there in the customer type with the most customers? | SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1 |
Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance. | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT avg(balance) FROM savings) |
List the name, location, mascot for all schools. | SELECT school_name , LOCATION , mascot FROM school |
Show all publishers which do not have a book in 1989. | SELECT publisher FROM book_club EXCEPT SELECT publisher FROM book_club WHERE YEAR = 1989 |
Show all the locations where no cinema has capacity over 800. | SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800 |
Find the names and number of works of the three artists who have produced the most songs. | SELECT T1.artist_name , count(*) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name GROUP BY T2.artist_name ORDER BY count(*) DESC LIMIT 3 |
Find all the papers published by the institution "Google". | SELECT 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 = "Google" |
Find the names of the swimmers who have no record. | SELECT name FROM swimmer WHERE id NOT IN (SELECT swimmer_id FROM record) |
What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix? | SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.drive... |
Show the name of the party that has at least two records. | SELECT Party FROM party GROUP BY Party HAVING COUNT(*) >= 2 |
List the names of climbers in descending order of points. | SELECT Name FROM climber ORDER BY Points DESC |
Which film has the highest rental rate? And what is the rate? | SELECT title , rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1 |
Count the number of distinct player positions. | SELECT count(DISTINCT POSITION) FROM player |
What is the average latitude and longitude of all starting stations for the trips? | SELECT avg(T1.lat) , avg(T1.long) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id |
Count the number of different software platforms. | SELECT count(DISTINCT Software_Platform) FROM device |
What are the locations that have gas stations owned by a company with a market value greater than 100? | SELECT T3.location FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.market_value > 100 |
What are the first names of all the students aged above 22? | SELECT Fname FROM STUDENT WHERE Age > 22 |
What is the name of the party form that is most common? | SELECT t1.form_name FROM forms AS t1 JOIN party_forms AS t2 ON t1.form_id = t2.form_id GROUP BY t2.form_id ORDER BY count(*) DESC LIMIT 1 |
What are the names of modern rooms that have a base price lower than $160 and two beds. | SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern'; |
What is the name of party with most number of members? | SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1 |
Show all locations that have train stations with at least 15 platforms and train stations with more than 25 total passengers. | SELECT DISTINCT LOCATION FROM station WHERE number_of_platforms >= 15 AND total_passengers > 25 |
find the number of medicines offered by each trade. | SELECT trade_name , count(*) FROM medicine GROUP BY trade_name |
What is the date of birth for the staff member named Janessa Sawayn? | SELECT date_of_birth FROM Staff WHERE first_name = "Janessa" AND last_name = "Sawayn"; |
Find the address and staff number of the shops that do not have any happy hour. | SELECT address , num_of_staff FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM happy_hour) |
How many distinct teams are involved in match seasons? | SELECT count(DISTINCT Team) FROM match_season |
What is the maximum elevation of all airports in the country of Iceland? | SELECT max(elevation) FROM airports WHERE country = 'Iceland' |
Compute the total salary that the player with first name Len and last name Barker received between 1985 to 1990. | SELECT sum(T1.salary) FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id WHERE T2.name_first = 'Len' AND T2.name_last = 'Barker' AND T1.year BETWEEN 1985 AND 1990; |
What are the title and maximum price of each film? | SELECT T2.title , max(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id |
Show the invoice number and the number of transactions for each invoice. | SELECT invoice_number , count(*) FROM Financial_transactions GROUP BY invoice_number |
What is the average number of working horses of farms with more than 5000 total number of horses? | SELECT avg(Working_Horses) FROM farm WHERE Total_Horses > 5000 |
What are the titles of courses that are offered in more than one department? | SELECT title FROM course GROUP BY title HAVING count(*) > 1 |
How many customers are there of each gender? | SELECT gender , count(*) FROM Customers GROUP BY gender |
Find the number of distinct courses that have enrolled students. | SELECT count(course_id) FROM Student_Course_Enrolment |
For each position, what is the maximum number of hours for students who spent more than 1000 hours training? | SELECT max(T1.HS) , pPos FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T1.HS > 1000 GROUP BY T2.pPos |
What are the cities that have more than 2 airports sorted by number of airports? | SELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*) |
List the official name and status of the city with the largest population. | SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1 |
Count the products that have the color description "white" or have the characteristic name "hot". | 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 JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "white" OR t3.characteristic_name = "hot" |
Find the booking start date and end date for the apartments that have more than two bedrooms. | SELECT T1.booking_start_date , T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 2 |
How many dorms are in the database? | SELECT count(*) FROM dorm |
What is the phone number and postal code of the address 1031 Daugavpils Parkway? | SELECT phone , postal_code FROM address WHERE address = '1031 Daugavpils Parkway' |
What are the names of the chairs of festivals, sorted in ascending order of the year held? | SELECT Chair_Name FROM festival_detail ORDER BY YEAR ASC |
Find all the order items whose product id is 11. What are the order item ids? | SELECT order_item_id FROM order_items WHERE product_id = 11 |
What are the names and addressed of customers who have both New and Pending orders? | SELECT T1.customer_name , T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "New" INTERSECT SELECT T1.customer_name , T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.... |
For each course id, how many students are registered and what are the course names? | SELECT T3.course_name , count(*) FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id JOIN courses AS T3 ON T2.course_id = T3.course_id GROUP BY T2.course_id |
Find the number of companies whose industry is "Banking" or "Conglomerate", | SELECT count(*) FROM Companies WHERE Industry = "Banking" OR Industry = "Conglomerate" |
What are the top three apartment types in terms of the average room count? Give me the | SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY avg(room_count) DESC LIMIT 3 |
List the names of clubs that do not have any players. | SELECT name FROM CLub WHERE Club_ID NOT IN (SELECT Club_ID FROM player) |
Find the name and population of district with population between 200000 and 2000000 | SELECT District_name , City_Population FROM district WHERE City_Population BETWEEN 200000 AND 2000000 |
Find the name of the products that have the color description "red" and have the characteristic name "fast". | SELECT product_name 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 JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "red" AND t3.characteristic_name = "fast" |
What are the first and last names of all drivers who participated in the Australian Grand Prix but not the Chinese Grand Prix? | SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T... |
What is the maximum stars and year for the most recent movie? | SELECT max(T1.stars) , T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT max(YEAR) FROM Movie) |
Find the name, headquarter and revenue of all manufacturers sorted by their revenue in the descending order. | SELECT name , headquarter , revenue FROM manufacturers ORDER BY revenue DESC |
Return the poll resource associated with the most candidates. | SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY count(*) DESC LIMIT 1 |
What is the name of the project that requires the fewest number of hours, and the names of the scientists assigned to it? | SELECT T2.name , T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT min(hours) FROM projects) |
What are the distinct last names of the students who have president votes and have 8741 as the advisor? | SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = PRESIDENT_Vote INTERSECT SELECT DISTINCT LName FROM STUDENT WHERE Advisor = "8741" |
Which documents have more than 1 draft copies? List document id and number of draft copies. | SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*) > 1; |
Which customers use "Cash" for payment method? Return the customer names. | SELECT customer_name FROM customers WHERE payment_method = "Cash" |
What are the first, middle, and last names of all individuals, ordered by last name? | SELECT individual_first_name , individual_middle_name , individual_last_name FROM individuals ORDER BY individual_last_name |
How many products are not made by Sony? | SELECT count(DISTINCT name) FROM products WHERE name NOT IN (SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony') |
What are the descriptions of the categories that products with product descriptions that contain the letter t are in? | 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%' |
How many customers do not have an account? | SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts) |
What is the name of the department that has the largest number of students enrolled? | SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY count(*) DESC LIMIT 1 |
Show the season, the player, and the name of the country that player belongs to. | SELECT T2.Season , T2.Player , T1.Country_name FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country |
which course has most number of registered students? | SELECT T1.course_name FROM courses AS T1 JOIN student_course_registrations AS T2 ON T1.course_id = T2.course_Id GROUP BY T1.course_id ORDER BY count(*) DESC LIMIT 1 |
Which countries has the most number of airlines? | SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1 |
What are all the employees without a department number? | SELECT * FROM employees WHERE department_id = "null" |
Show the name of track and the number of races in each track. | SELECT T2.name , count(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id |
Return the address content for the customer whose name is "Maudie Kertzmann". | SELECT t3.address_content 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 WHERE t1.customer_name = "Maudie Kertzmann" |
Which department has the highest average instructor salary? | SELECT dept_name FROM instructor GROUP BY dept_name ORDER BY avg(salary) DESC LIMIT 1 |
Show all publishers and the number of books for each publisher. | SELECT publisher , count(*) FROM book_club GROUP BY publisher |
Which trip started from the station with the largest dock count? Give me the trip id. | SELECT T1.id FROM trip AS T1 JOIN station AS T2 ON T1.start_station_id = T2.id ORDER BY T2.dock_count DESC LIMIT 1 |
What are the names of wines that are more expensive then all wines made in the year 2006? | SELECT Name FROM WINE WHERE Price > (SELECT max(Price) FROM WINE WHERE YEAR = 2006) |
Show the statement id and the statement detail for the statement with most number of accounts. | SELECT T1.statement_id , T2.statement_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id GROUP BY T1.statement_id ORDER BY count(*) DESC LIMIT 1 |
List the brands of lenses that took both a picture of mountains with range 'Toubkal Atlas' and a picture of mountains with range 'Lasta Massif' | SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Toubkal Atlas' INTERSECT SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHE... |
What are the different years for all competitions that are not of type equal to tournament? | SELECT DISTINCT YEAR FROM competition WHERE Competition_type != "Tournament" |
What are the names of the instructors in the Comp. Sci. department who earn more than 80000? | SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.' AND salary > 80000 |
Return the distinct customer details. | SELECT DISTINCT customer_details FROM Customers |
What are the maximum and minimum settlement amount on record? | SELECT max(settlement_amount) , min(settlement_amount) FROM settlements |
Count the number of voting records for each election cycle. | SELECT Election_Cycle , count(*) FROM VOTING_RECORD GROUP BY Election_Cycle |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.