anchor
stringlengths
10
14.3k
positive
stringlengths
10
14.9k
What is the average fastest lap speed for races held after 2004, for each race, 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 IDs of customers whose name contains "Diana".
SELECT customer_id FROM customers WHERE customer_name LIKE "%Diana%"
List the document type code for the document with the id 2.
SELECT document_type_code FROM Documents WHERE document_id = 2;
What is the average rating stars and title for the oldest movie?
SELECT avg(T1.stars) , T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT min(YEAR) FROM Movie)
find the name of driver who is driving the school bus with the longest working history.
SELECT t1.name FROM driver AS t1 JOIN school_bus AS t2 ON t1.driver_id = t2.driver_id ORDER BY years_working DESC LIMIT 1
What is the total number of clubs that have less than 10 medals in total?
SELECT count(*) FROM club_rank WHERE Total < 10
How many flights have a velocity larger than 200?
SELECT count(*) FROM flight WHERE velocity > 200
Which faculty members advise two ore more students? Give me their faculty ids.
SELECT T1.FacID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID HAVING count(*) >= 2
What is the type of vocals that the band member with the last name "Heilo" played the most?
SELECT TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE lastname = "Heilo" GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
Find the name of the department that has the fewest members.
SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MEMBER_OF AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY count(*) ASC LIMIT 1
What is the theme, date, and attendance for the exhibition in year 2004?
SELECT T2.theme , T1.date , T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
For each payment method, how many payments were made?
SELECT payment_method_code , count(*) FROM Customer_Payments GROUP BY payment_method_code;
What are the names of customers who have a savings balance lower than their checking balance, and what is the total of their checking and savings balances?
SELECT T1.name , T3.balance + T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance < T2.balance
What are the first names of the professors who do not play Canoeing or Kayaking as activities?
SELECT lname FROM faculty WHERE rank = 'Professor' EXCEPT SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking'
What is the name of the dorm with both a TV Lounge and Study Room listed as amenities?
SELECT T1.dorm_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 T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.ameni...
What are the descriptions of the courses with name "database"?
SELECT course_description FROM COURSES WHERE course_name = "database"
Show the movie titles and book titles for all companies in China.
SELECT T1.title , T3.book_title FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id = T2.movie_id JOIN book_club AS T3 ON T3.book_club_id = T2.book_club_id WHERE T2.incorporated_in = 'China'
How many songs have a lead vocal?
SELECT count(DISTINCT title) FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE TYPE = "lead"
List the distinct positions of pilots older than 30.
SELECT DISTINCT POSITION FROM pilot WHERE Age > 30
How many farms are there?
SELECT count(*) FROM farm
return the smallest salary for every departments.
SELECT MIN(salary) , department_id FROM employees GROUP BY department_id
Show the accelerator names and supporting operating systems that are not compatible with the browser named 'Opera'.
SELECT name , operating_system FROM web_client_accelerator EXCEPT SELECT T1.name , T1.operating_system FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.name = 'Opera'
What is the average number of votes of representatives from party "Republican"?
SELECT avg(T1.Votes) FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID WHERE T2.Party = "Republican"
How many students are older than average for each gender?
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
What is the total number of faculty members?
SELECT count(*) FROM Faculty
How many invoices correspond to each order id?
SELECT order_id , count(*) FROM Invoices GROUP BY order_id
What are the manager's first name, last name and id who won the most manager award?
SELECT T1.name_first , T1.name_last , T2.player_id FROM player AS T1 JOIN manager_award AS T2 ON T1.player_id = T2.player_id GROUP BY T2.player_id ORDER BY count(*) DESC LIMIT 1;
Return the minimum, maximum, and average seating across all tracks.
SELECT min(seating) , max(seating) , avg(seating) FROM track
What are the first and last name of all biology professors?
SELECT T3.EMP_FNAME , T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = "Biology"
What are the countries of all airlines whose names start with Orbit?
SELECT country FROM airlines WHERE name LIKE 'Orbit%'
Show the fleet series of the aircrafts flied by pilots younger than 34
SELECT T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID WHERE T3.Age < 34
How many faculty is there in total in the year of 2002?
SELECT sum(faculty) FROM faculty WHERE YEAR = 2002
Show the name and opening year for three churches that opened most recently.
SELECT name , open_date FROM church ORDER BY open_date DESC LIMIT 3
What are the names of all airports in Cuba or Argentina?
SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina'
List the names of players in ascending order of votes.
SELECT Player_name FROM player ORDER BY Votes ASC
Show the faculty id of each faculty member, along with the number of students he or she advises.
SELECT T1.FacID , count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID
What are the names of representatives in descending order of votes?
SELECT T2.Name FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID ORDER BY votes DESC
Show the distinct position of players from college UCLA or Duke.
SELECT DISTINCT POSITION FROM match_season WHERE College = "UCLA" OR College = "Duke"
Return the average money requested across all entrepreneurs.
SELECT avg(Money_Requested) FROM entrepreneur
Find the first name and major of the students who are not allegry to soy.
SELECT fname , major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Soy")
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