anchor
stringlengths
10
14.3k
positive
stringlengths
10
14.9k
Find the city and state of the bank branch named morningside.
SELECT city , state FROM bank WHERE bname = 'morningside'
What is the total share (in percent) of all the channels owned by CCTV?
SELECT sum(Share_in_percent) FROM channel WHERE OWNER = 'CCTV'
What are the names of products with price at most 200?
SELECT name FROM products WHERE price <= 200
What are the ids of the students who registered for course 301 most recently?
SELECT student_id FROM student_course_attendance WHERE course_id = 301 ORDER BY date_of_attendance DESC LIMIT 1
Find the total hours of the projects that scientists named Michael Rogers or Carol Smith are assigned to.
SELECT sum(T2.hours) FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name = 'Michael Rogers' OR T3.name = 'Carol Smith'
What is the name of the event that happened in the most recent year?
SELECT name FROM event ORDER BY YEAR DESC LIMIT 1
What are the names of the amenities that Smith Hall has?
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'
Tell me the booking status code for the apartment with number "Suite 634".
SELECT T1.booking_status_code FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.apt_number = "Suite 634"
What is the total number of gas stations that opened between 2000 and 2005?
SELECT count(*) FROM gas_station WHERE open_year BETWEEN 2000 AND 2005
What is the id and trade name of the medicines can interact with at least 3 enzymes?
SELECT T1.id , T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 3
What are the unique labels for the albums?
SELECT count(DISTINCT label) FROM albums
Show ids for all the male faculty.
SELECT FacID FROM Faculty WHERE Sex = 'M'
How many games in total did team Boston Red Stockings attend from 2000 to 2010?
SELECT sum(T1.attendance) FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year BETWEEN 2000 AND 2010;
How many services are there?
SELECT count(*) FROM services
What is the weight of the shortest person?
SELECT Weight FROM people ORDER BY Height ASC LIMIT 1
Find the names of the users whose number of followers is greater than that of the user named "Tyler Swift".
SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING count(*) > (SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 WHERE T1.name = 'Tyler Swift')
List all the contact channel codes that were used less than 5 times.
SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING count(customer_id) < 5
Show the prices of the products named "Dining" or "Trading Policy".
SELECT Product_Price FROM Products WHERE Product_Name = "Dining" OR Product_Name = "Trading Policy"
Return the weight of the shortest person.
SELECT Weight FROM people ORDER BY Height ASC LIMIT 1
Show total hours per week and number of games played for students under 20.
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
Count different addresses of each school.
SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code
What are the names of artists who did not have an exhibition in 2004?
SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
Find the names of swimmers who has a result of "win".
SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win'
What is the name of the student who has the highest total credits in the History department.
SELECT name FROM student WHERE dept_name = 'History' ORDER BY tot_cred DESC LIMIT 1
What are the ids of suppliers which have an average amount purchased of above 50000 or below 30000?
SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased) > 50000 OR avg(total_amount_purchased) < 30000
How many instruments does the song "Badlands" use?
SELECT count(DISTINCT instrument) FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Badlands"
Which tourist attractions does the visitor with detail 'Vincent' visit?
SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID JOIN VISITORS AS T3 ON T2.Tourist_ID = T3.Tourist_ID WHERE T3.Tourist_Details = "Vincent"
What are the names of wines with scores higher than 90?
SELECT Name FROM WINE WHERE score > 90
What are the names and locations of all enzymes listed?
SELECT name , LOCATION FROM enzyme
What is the maximum enrollment across all schools?
SELECT max(Enrollment) FROM university
Show all dates of transactions whose type code is "SALE".
SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
What is the name of the document with the most number of sections?
SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1
How many faculty members do we have for each faculty rank?
SELECT rank , count(*) FROM Faculty GROUP BY rank
What is the course title of the prerequisite of course Mobile Computing?
SELECT title FROM course WHERE course_id IN (SELECT T1.prereq_id FROM prereq AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.title = 'Mobile Computing')
Return the minimum, average and maximum distances traveled across all aircrafts.
SELECT min(distance) , avg(distance) , max(distance) FROM Aircraft
What information do you have on colleges sorted by increasing enrollment numbers?
SELECT * FROM College ORDER BY enr
Give me a list of cities whose temperature in Mar is lower than that in July and which have also served as host cities?
SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Jul INTERSECT SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city
For each zip code, find the ids of all trips that have a higher average mean temperature above 60?
SELECT T1.id FROM trip AS T1 JOIN weather AS T2 ON T1.zip_code = T2.zip_code GROUP BY T2.zip_code HAVING avg(T2.mean_temperature_f) > 60
What are the codes of card types that have 5 or more cards?
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5
What are the names of all clubs?
SELECT clubname FROM club
Find the names of customers who never placed an order.
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id
Find the first and last name of all the students of age 18 who have vice president votes.
SELECT DISTINCT T1.Fname , T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.VICE_President_VOTE WHERE T1.age = 18
What are the names of tracks that contain the the word you in them?
SELECT Name FROM TRACK WHERE Name LIKE '%you%'
Find the name of bank branch that provided the greatest total amount of loans.
SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY sum(T2.amount) DESC LIMIT 1
Show the investors shared by entrepreneurs that requested more than 140000 and entrepreneurs that requested less than 120000.
SELECT Investor FROM entrepreneur WHERE Money_Requested > 140000 INTERSECT SELECT Investor FROM entrepreneur WHERE Money_Requested < 120000
How many games has each stadium held?
SELECT T1.id , count(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id = T2.stadium_id GROUP BY T1.id
Show the id and name of the aircraft with the maximum distance.
SELECT aid , name FROM Aircraft ORDER BY distance DESC LIMIT 1
Which customer made the most orders? Find the customer name.
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
What is the total number of airlines?
SELECT count(*) FROM airlines
What is the address of the restaurant Subway?
SELECT Address FROM Restaurant WHERE ResName = "Subway";
How many institutions do not have an associated protein in our record?
SELECT count(*) FROM institution WHERE institution_id NOT IN (SELECT institution_id FROM protein)
What is the name of tracks whose genre is Rock?
SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock";
What are the drivers' first, last names and id who had more than 8 pit stops or participated in more than 5 race results?
SELECT T1.forename , T1.surname , T1.driverid FROM drivers AS T1 JOIN pitstops AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING count(*) > 8 UNION SELECT T1.forename , T1.surname , T1.driverid FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING count(*)...
What is the first and last name of the youngest student with a GPA above 3, and what is their GPA?
SELECT stu_fname , stu_lname , stu_gpa FROM student WHERE stu_gpa > 3 ORDER BY stu_dob DESC LIMIT 1
Which student's age is older than 18 and is majoring in 600? List each student's first and last name.
SELECT Fname , Lname FROM Student WHERE Age > 18 AND Major = 600;
What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named 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...
list names of all departments ordered by their names.
SELECT dept_name FROM department ORDER BY dept_name
Find the name and total checking and savings balance of the accounts whose savings balance is lower than corresponding checking balance.
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
Which customers have used the service named "Close a policy" or "Upgrade a policy"? Give me the customer names.
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" OR t3.service_name = "Upgrade a policy"
How many different users wrote some reviews?
SELECT count(DISTINCT u_id) FROM review
How many customers don't have an account?
SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts)
List all customer status codes and the number of customers having each status code.
SELECT customer_status_code , count(*) FROM Customers GROUP BY customer_status_code;
List the names of representatives that have not participated in elections listed here.
SELECT Name FROM representative WHERE Representative_ID NOT IN (SELECT Representative_ID FROM election)
Find the name of the company that has the least number of phone models. List the company name and the number of phone model produced by that company.
SELECT Company_name , count(*) FROM phone GROUP BY Company_name ORDER BY count(*) ASC LIMIT 1;
List the order id, customer id for orders in Cancelled status, ordered by their order dates.
SELECT order_id , customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date
Find the name of the customer who made the most orders.
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
What are the first year and last year of the parties whose theme is "Spring" or "Teqnology"?
SELECT First_year , Last_year FROM party WHERE Party_Theme = "Spring" OR Party_Theme = "Teqnology"
Show different locations of railways along with the corresponding number of railways at each location.
SELECT LOCATION , COUNT(*) FROM railway GROUP BY LOCATION
Show different types of ships and the average tonnage of ships of each type.
SELECT TYPE , avg(Tonnage) FROM ship GROUP BY TYPE
How many stations are in Mountain View?
SELECT COUNT(*) FROM station WHERE city = "Mountain View"
What is the salaray and name of the employee that is certified to fly the most planes?
SELECT T1.name , T1.salary FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid GROUP BY T1.eid ORDER BY count(*) DESC LIMIT 1
What is the id of the account with the most transactions?
SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY count(*) DESC LIMIT 1
How many different departments are there?
SELECT count(DISTINCT dept_name) FROM department
What is the total quantity of products purchased by "Rodrick Heaney"?
SELECT sum(t3.order_quantity) 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 WHERE t1.customer_name = "Rodrick Heaney"
Find the name of physicians who are affiliated with both Surgery and Psychiatry departments.
SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T3.name = 'Surgery' INTERSECT SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.d...
List the names of all distinct nurses ordered by alphabetical order?
SELECT DISTINCT name FROM nurse ORDER BY name
Find the name and savings balance of the top 3 accounts with the highest saving balance sorted by savings balance in descending order.
SELECT T1.name , T2.balance FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T2.balance DESC LIMIT 3
What is the description of the type of the company who concluded its contracts most recently?
SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id JOIN Ref_Company_Types AS T3 ON T1.company_type_code = T3.company_type_code ORDER BY T2.contract_end_date DESC LIMIT 1
What is the order id and order details for the order more than two invoices.
SELECT T2.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING count(*) > 2
Which cities have at least one customer but no performer?
SELECT T1.City_Town FROM Addresses AS T1 JOIN Customers AS T2 ON T1.Address_ID = T2.Address_ID EXCEPT SELECT T1.City_Town FROM Addresses AS T1 JOIN Performers AS T2 ON T1.Address_ID = T2.Address_ID
Find the total budgets of the Marketing or Finance department.
SELECT sum(budget) FROM department WHERE dept_name = 'Marketing' OR dept_name = 'Finance'
Show the location code, the starting date and ending data in that location for all the documents.
SELECT location_code , date_in_location_from , date_in_locaton_to FROM Document_locations
What is the total number of students enrolled in schools without any goalies?
SELECT sum(enr) FROM college WHERE cName NOT IN (SELECT cName FROM tryout WHERE pPos = "goalie")
List the distinct payment method codes with the number of orders made
SELECT payment_method_code , count(*) FROM INVOICES GROUP BY payment_method_code
What are the ids and first names of customers who do not hold a credit card?
SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT T1.customer_id , T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit"
Give me the maximum low temperature and average precipitation at the Amersham station.
SELECT max(t1.low_temperature) , avg(t1.precipitation) FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id WHERE t2.network_name = "Amersham"
What are the products with the maximum page size A4 that also have a pages per minute color smaller than 5?
SELECT product FROM product WHERE max_page_size = "A4" AND pages_per_minute_color < 5
Return the names and ids of customers who have TN in their address.
SELECT customer_name , customer_id FROM customers WHERE customer_address LIKE "%TN%"
How many services has each resident requested? List the resident id, details, and the count in descending order of the count.
SELECT T1.resident_id , T1.other_details , count(*) FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id = T2.resident_id GROUP BY T1.resident_id ORDER BY count(*) DESC
In which state is the college that Charles attends?
SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName JOIN player AS T3 ON T2.pID = T3.pID WHERE T3.pName = 'Charles'
Find the checking balance of the accounts whose savings balance is higher than the average savings balance.
SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM savings))
Show the phone, room, and building for the faculty named Jerry Prince.
SELECT phone , room , building FROM Faculty WHERE Fname = "Jerry" AND Lname = "Prince"
Return the type code of the document named "David CV".
SELECT document_type_code FROM documents WHERE document_name = "David CV"
find the rank, company names, market values of the companies in the banking industry order by their sales and profits in billion.
SELECT rank , company , market_value FROM company WHERE main_industry = 'Banking' ORDER BY sales_billion , profits_billion
Show the name, average attendance, total attendance for stadiums where no accidents happened.
SELECT name , average_attendance , total_attendance FROM stadium EXCEPT SELECT T2.name , T2.average_attendance , T2.total_attendance FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id
Please show the countries and the number of climbers from each country.
SELECT Country , COUNT(*) FROM climber GROUP BY Country
Show the number of male and female assistant professors.
SELECT sex , count(*) FROM Faculty WHERE rank = "AsstProf" GROUP BY sex
How many products have their color described as 'white' or have a characteristic with the 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"
What is the average number of cities of markets with low film market estimate bigger than 10000?
SELECT avg(T2.Number_cities) FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T1.Low_Estimate > 10000
Show the name for regions and the number of storms for each region.
SELECT T1.region_name , count(*) FROM region AS T1 JOIN affected_region AS T2 ON T1.region_id = T2.region_id GROUP BY T1.region_id