question stringlengths 43 589 | query stringlengths 19 598 |
|---|---|
How many customers in total?
Schema:
- Customers(BIGINT, COUNT, Customer_Details, Customer_ID, Customer_name, Mar, Rat, TRY_CAST, V, address_line_1, address_line_2, amount_outstanding, ... (25 more)) | SELECT COUNT(*) AS num_customers FROM Customers; |
What is the document type code with most number of documents?
Schema:
- Documents(COUNT, Document_Description, Document_ID, Document_Name, Document_Type_Code, I, K, Project_ID, Robb, Template_ID, access_count, document_id, ... (7 more)) | SELECT Document_Type_Code FROM Documents WHERE Document_Type_Code IS NOT NULL GROUP BY Document_Type_Code ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
Find all the films longer than 100 minutes, or rated PG, except those who cost more than 200 for replacement. List the titles.?
Schema:
- film(COUNT, Directed_by, Director, Gross_in_dollar, JO, LENGTH, Studio, T1, Title, language_id, rating, rental_rate, ... (3 more)) | SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' AND title NOT IN (SELECT title FROM film WHERE replacement_cost > 200); |
What is the continent name which Anguilla belongs to?
Schema:
- country(Capital, Continent, Country_name, Engl, GNP, GovernmentForm, HeadOfState, IndepYear, LifeExpectancy, M, Name, Official_native_language, ... (4 more)) | SELECT Continent FROM country WHERE Name = 'Anguilla'; |
how many papers does sigir have ?
Schema:
- venue(venueId, venueName)
- paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year) | SELECT DISTINCT COUNT(T1.paperId) AS num_papers FROM venue AS T2 JOIN paper AS T1 ON T2.venueId = T1.venueId WHERE T2.venueName = 'sigir'; |
Has Peter Mertens and Dina Barbian written a paper together ?
Schema:
- writes(...)
- author(...) | SELECT DISTINCT T3.paperId FROM writes AS T3 JOIN author AS T2 ON T3.authorId = T2.authorId JOIN writes AS T4 ON T4.paperId = T3.paperId JOIN author AS T1 ON T4.authorId = T1.authorId WHERE T2.authorName = 'Peter Mertens' AND T1.authorName = 'Dina Barbian'; |
Find the name and category of the most expensive product.?
Schema:
- Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more)) | SELECT product_name, product_category_code FROM Products ORDER BY product_price DESC NULLS LAST LIMIT 1; |
Return the issue dates of volumes that are by the artist named Gorgoroth.?
Schema:
- artist(Age, Artist, Country, Famous_Release_date, Famous_Title, Year_Join, artist_name, country, gender)
- volume(Artist_ID, Issue_Date, Song, Weeks_on_Top) | SELECT T2.Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.Artist = 'Gorgoroth'; |
How many degrees does the engineering department have?
Schema:
- Departments(...)
- Degree_Programs(degree_summary_name, department_id) | SELECT COUNT(*) AS num_degrees FROM Departments AS T1 JOIN Degree_Programs AS T2 ON T1.department_id = T2.department_id WHERE T1.department_name = 'engineer'; |
What are the country names, area and population which has both roller coasters with speed higher?
Schema:
- country(Capital, Continent, Country_name, Engl, GNP, GovernmentForm, HeadOfState, IndepYear, LifeExpectancy, M, Name, Official_native_language, ... (4 more))
- roller_coaster(DOUBLE, Height, LENGTH, Park, Speed, Status, TRY_CAST) | SELECT T1.Name, T1.Area, T1.Population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE TRY_CAST(T2.Speed AS DOUBLE) > 60 AND EXISTS (SELECT 1 FROM roller_coaster AS T3 WHERE T1.Country_ID = T3.Country_ID AND TRY_CAST(T3.Speed AS DOUBLE) < 55); |
What is the location code for the country "Canada"?
Schema:
- Ref_Locations(Location_Code, Location_Description, Location_Name) | SELECT Location_Code FROM Ref_Locations WHERE Location_Name = 'Canada'; |
Which address holds the most number of students currently? List the address id and all lines.?
Schema:
- Addresses(address_content, city, country, line_1, line_1_number_building, line_2, state_province_county, town_city, zip_postcode)
- Students(cell_mobile_number, current_address_id, date_first_registered, date_left, date_of_latest_logon, email_address, family_name, first_name, last_name, login_name, middle_name, other_student_details, ... (1 more)) | SELECT T1.address_id, T1.line_1, T1.line_2, T1.line_3 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.current_address_id GROUP BY T1.address_id, T1.line_1, T1.line_2, T1.line_3 ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
Count the number of bank branches.?
Schema:
- bank(SUM, bname, city, morn, no_of_customers, state) | SELECT COUNT(*) AS num_branches FROM bank; |
Find the average rank of winners in all matches.?
Schema:
- matches_(COUNT, T1, loser_age, loser_name, minutes, tourney_name, winner_age, winner_hand, winner_name, winner_rank, winner_rank_points, year) | SELECT AVG(winner_rank) AS avg_winner_rank FROM matches_; |
What is the last name of the student who has a cat that is 3 years old?
Schema:
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
- Has_Pet(...)
- Pets(PetID, PetType, pet_age, weight) | SELECT T1.LName FROM Student AS T1 JOIN Has_Pet AS T2 ON T1.StuID = T2.StuID JOIN Pets AS T3 ON T3.PetID = T2.PetID WHERE T3.pet_age = 3 AND T3.PetType = 'cat'; |
What is the average room count of the apartments whose booking status code is "Provisional"?
Schema:
- Apartment_Bookings(booking_end_date, booking_start_date, booking_status_code)
- Apartments(AVG, COUNT, INT, SUM, TRY_CAST, apt_number, apt_type_code, bathroom_count, bedroom_count, room_count) | SELECT AVG(TRY_CAST(room_count AS INT)) AS avg_room_count FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Provisional'; |
Find the total and average amount paid in claim headers.?
Schema:
- Claim_Headers(Amount_Piad) | SELECT SUM(Amount_Piad) AS total_amount_paid, AVG(Amount_Piad) AS avg_amount_paid FROM Claim_Headers; |
What are the countries that have at least two perpetrators?
Schema:
- perpetrator(Country, Date, Injured, Killed, Location, Year) | SELECT Country, COUNT(*) AS num_perpetrators FROM perpetrator WHERE Country IS NOT NULL GROUP BY Country HAVING COUNT(*) >= 2; |
How many flights fly from Aberdeen to Ashley?
Schema:
- flights(DestAirport, FlightNo, SourceAirport)
- airports(AirportCode, AirportName, Argent, COUNT, City, Country, city, country, elevation, name) | SELECT COUNT(*) AS num_flights FROM flights AS T1 JOIN airports AS T2 ON T1.DestAirport = T2.AirportCode JOIN airports AS T3 ON T1.SourceAirport = T3.AirportCode WHERE T2.City = 'Ashley' AND T3.City = 'Aberdeen'; |
Find the name of students who didn't take any course from Biology department.?
Schema:
- student(COUNT, H, dept_name, name, tot_cred)
- takes(COUNT, semester, year)
- course(COUNT, JO, SUM, Stat, T1, course_id, credits, dept_name, title) | SELECT name FROM student WHERE ID NOT IN (SELECT T1.ID FROM takes AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.dept_name = 'Biology'); |
Show the company name with the number of gas station.?
Schema:
- station_company(...)
- company(Bank, COUNT, Company, Headquarters, Industry, JO, Main_Industry, Market_Value, Name, Profits_in_Billion, Rank, Retail, ... (4 more)) | SELECT T2.Company, COUNT(*) AS num_gas_stations FROM station_company AS T1 JOIN company AS T2 ON T1.Company_ID = T2.Company_ID GROUP BY T1.Company_ID, T2.Company; |
how many cities are there in the us?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more)) | SELECT COUNT(city_name) AS num_cities FROM city WHERE country_name = 'united states'; |
which state has the smallest population density?
Schema:
- state(M, area, aust, capital, country_name, density, population, population_per_square_km, rhode, state_name, wyom) | SELECT state_name FROM state WHERE density = (SELECT MIN(density) FROM state); |
Compute the average price of all products with manufacturer code equal to 2.?
Schema:
- Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more)) | SELECT AVG(Price) AS avg_price FROM Products WHERE Manufacturer = 2; |
return me the area of PVLDB .?
Schema:
- domain(...)
- domain_journal(...)
- journal(Theme, homepage, name) | SELECT T3.name FROM domain AS T3 JOIN domain_journal AS T1 ON T3.did = T1.did JOIN journal AS T2 ON T2.jid = T1.jid WHERE T2.name = 'PVLDB'; |
Give me the product type, name and price for all the products supplied by supplier id 3.?
Schema:
- Product_Suppliers(COUNT, DOUBLE, TRY_CAST, product_id, supplier_id)
- Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more)) | SELECT T2.product_type_code, T2.product_name, T2.product_price FROM Product_Suppliers AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 3; |
which state has the greatest population?
Schema:
- state(M, area, aust, capital, country_name, density, population, population_per_square_km, rhode, state_name, wyom) | SELECT state_name FROM state WHERE population = (SELECT MAX(population) FROM state); |
What is the name of the media type that is least common across all tracks?
Schema:
- MediaType(...)
- Track(Milliseconds, Name, UnitPrice) | SELECT T1.Name FROM MediaType AS T1 JOIN Track AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.MediaTypeId, T1.Name ORDER BY COUNT(*) ASC NULLS LAST LIMIT 1; |
What are each owner's first name, last name, and the size of their dog?
Schema:
- Owners(email_address, first_name, last_name, state)
- Dogs(abandoned_yn, age, breed_code, date_arrived, date_departed, name, size_code, weight) | SELECT T1.first_name, T1.last_name, T2.size_code FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id = T2.owner_id; |
What are the campuses that had between 600 and 1000 faculty members in 2004?
Schema:
- Campuses(Campus, County, Franc, Location)
- faculty(Faculty) | 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; |
List the names of conductors in ascending order of age.?
Schema:
- conductor(Age, Name, Nationality, Year_of_Work) | SELECT Name FROM conductor ORDER BY Age ASC NULLS LAST; |
What are all the employees without a department number?
Schema:
- employees(COMMISSION_PCT, DEPARTMENT_ID, EMAIL, EMPLOYEE_ID, FIRST_NAME, HIRE_DATE, JOB_ID, LAST_NAME, M, MANAGER_ID, PHONE_NUMBER, SALARY, ... (12 more)) | SELECT * FROM employees WHERE DEPARTMENT_ID IS NULL; |
what state is springfield in?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more)) | SELECT state_name FROM city WHERE city_name = 'springfield'; |
What is the average GNP and total population in all nations whose government is US territory?
Schema:
- country(Capital, Continent, Country_name, Engl, GNP, GovernmentForm, HeadOfState, IndepYear, LifeExpectancy, M, Name, Official_native_language, ... (4 more)) | SELECT AVG(GNP) AS avg_gnp, SUM(Population) AS total_population FROM country WHERE GovernmentForm = 'US Territory'; |
List the names of all genres in alphabetical oder, together with its ratings.?
Schema:
- genre(g_name, rating) | SELECT g_name, rating FROM genre ORDER BY g_name ASC NULLS LAST; |
What are the ids, version numbers, and type codes for each template?
Schema:
- Templates(COUNT, M, Template_ID, Template_Type_Code, Version_Number) | SELECT Template_ID, Version_Number, Template_Type_Code FROM Templates; |
Which club has the most members majoring in "600"?
Schema:
- Club(ClubDesc, ClubLocation, ClubName, Enterpr, Gam, Hopk, Tenn)
- Member_of_club(...)
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age) | SELECT T1.ClubName FROM Club AS T1 JOIN Member_of_club AS T2 ON T1.ClubID = T2.ClubID JOIN Student AS T3 ON T2.StuID = T3.StuID WHERE T3.Major = '600' GROUP BY T1.ClubName ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
How many distinct students have been in detention?
Schema:
- Students_in_Detention(student_id) | SELECT COUNT(DISTINCT student_id) AS num_students FROM Students_in_Detention; |
What is the name of the project that has a scientist assigned to it whose name contains 'Smith'?
Schema:
- AssignedTo(Scientist)
- Projects(COUNT, Hours, Name, Project_Details, Project_ID, organ, organisation_id, project_details)
- Scientists(Name) | SELECT T2.Name 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 LIKE '%Smith%'; |
return me the authors who have cooperated both with " H. V. Jagadish " and " Divesh Srivastava " .?
Schema:
- writes(...)
- author(...)
- publication(COUNT, Mak, Price, Publ, Publication_Date, Publisher, T1, abstract, citation_num, reference_num, title, year) | SELECT T2.name FROM writes AS T4 JOIN author AS T2 ON T4.aid = T2.aid JOIN publication AS T7 ON T4.pid = T7.pid JOIN writes AS T5 ON T5.pid = T7.pid JOIN writes AS T6 ON T6.pid = T7.pid JOIN author AS T1 ON T5.aid = T1.aid JOIN author AS T3 ON T6.aid = T3.aid WHERE T1.name = 'H. V. Jagadish' AND T3.name = 'Divesh Srivastava'; |
What is allergy type of a cat allergy?
Schema:
- Allergy_Type(Allergy, AllergyType, COUNT) | SELECT AllergyType FROM Allergy_Type WHERE Allergy = 'Cat'; |
Return the dates of ceremony corresponding to music festivals that had the category "Best Song" and result "Awarded".?
Schema:
- music_festival(COUNT, Category, Date_of_ceremony, Result) | SELECT Date_of_ceremony FROM music_festival WHERE Category = 'Best Song' AND "Result" = 'Awarded'; |
Find the number of users who did not write any review.?
Schema:
- useracct(...)
- review(i_id, rank, rating, text) | SELECT COUNT(*) AS num_users FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review); |
How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?
Schema:
- Institution(COUNT, Enrollment, Founded, Type)
- protein(...) | SELECT COUNT(*) AS num_proteins FROM Institution AS T1 JOIN protein AS T2 ON T1.Institution_id = T2.Institution_id WHERE T1.Founded > 1880 OR T1.Type = 'Private'; |
Show all company names with a movie directed in year 1999.?
Schema:
- movie(Budget_million, Director, Find, Gross_worldwide, T1, Title, Year, budget, release_year, title)
- culture_company(...) | SELECT T2.Company_name FROM movie AS T1 JOIN culture_company AS T2 ON CAST(T1.movie_id AS TEXT) = T2.movie_id WHERE T1."Year" = 1999; |
How many products are there in the records?
Schema:
- Catalog_Contents(capacity, catalog_entry_name, height, next_entry_id, price_in_dollars, price_in_euros, product_stock_number) | SELECT COUNT(*) AS num_products FROM Catalog_Contents; |
which states does the ohio river pass through?
Schema:
- river(COUNT, DIST, LENGTH, M, country_name, illino, m, river_name, traverse) | SELECT traverse FROM river WHERE river_name = 'ohio'; |
What are the first names of all students who live in the dorm with the most amenities?
Schema:
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
- Lives_in(...)
- Dorm(dorm_name, gender, student_capacity)
- Has_amenity(dormid)
- Dorm_amenity(amenity_name) | SELECT T1.Fname FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM Dorm AS T3 JOIN Has_amenity AS T4 ON T3.dormid = T4.dormid JOIN Dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T2.dormid, T3.dormid ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1); |
What are the ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000?
Schema:
- Order_Items(COUNT, DOUBLE, INT, TRY_CAST, order_id, order_item_id, order_quantity, product_id, product_quantity)
- Product_Suppliers(COUNT, DOUBLE, TRY_CAST, product_id, supplier_id) | SELECT DISTINCT product_id FROM (SELECT product_id FROM Order_Items WHERE product_id IS NOT NULL GROUP BY product_id HAVING COUNT(*) > 3 UNION ALL SELECT product_id FROM Product_Suppliers WHERE product_id IS NOT NULL GROUP BY product_id HAVING SUM(TRY_CAST(total_amount_purchased AS DOUBLE)) > 80000); |
papers using WebKB?
Schema:
- paperDataset(...)
- dataset(...)
- paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year) | SELECT DISTINCT T3.paperId FROM paperDataset AS T2 JOIN dataset AS T1 ON T2.datasetId = T1.datasetId JOIN paper AS T3 ON T3.paperId = T2.paperId WHERE T1.datasetName = 'WebKB'; |
Please show the names of the buildings whose status is "on-hold", in ascending order of stories.?
Schema:
- buildings(Height, Status, Stories, name) | SELECT name FROM buildings WHERE Status = 'on-hold' ORDER BY Stories ASC NULLS LAST; |
What are names of customers who never ordered product Latte.?
Schema:
- Customers(BIGINT, COUNT, Customer_Details, Customer_ID, Customer_name, Mar, Rat, TRY_CAST, V, address_line_1, address_line_2, amount_outstanding, ... (25 more))
- Customer_Orders(customer_id, order_date, order_id, order_shipping_charges)
- Order_Items(COUNT, DOUBLE, INT, TRY_CAST, order_id, order_item_id, order_quantity, product_id, product_quantity)
- Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more)) | SELECT customer_name FROM Customers WHERE customer_name NOT IN (SELECT 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 JOIN Products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_details = 'Latte'); |
What is the title, phone number and hire date for the employee named Nancy Edwards?
Schema:
- employees(COMMISSION_PCT, DEPARTMENT_ID, EMAIL, EMPLOYEE_ID, FIRST_NAME, HIRE_DATE, JOB_ID, LAST_NAME, M, MANAGER_ID, PHONE_NUMBER, SALARY, ... (12 more)) | SELECT title, phone, hire_date FROM employees WHERE first_name = 'Nancy' AND last_name = 'Edwards'; |
What are the positions with both players having more than 20 points and less than 10 points.?
Schema:
- player(Age, COUNT, Gender, Occupation, Player, Player_name, Po, Points, Position, Residence, Sponsor_name, T1, ... (12 more)) | SELECT DISTINCT T1."Position" FROM player AS T1 JOIN player AS T2 ON T1."Position" = T2."Position" WHERE T1.Points > 20 AND T2.Points < 10; |
Show the nations that have both hosts older than 45 and hosts younger than 35.?
Schema:
- host(Age, COUNT, Name, Nationality) | SELECT DISTINCT Nationality FROM host WHERE Nationality IN (SELECT Nationality FROM host WHERE TRY_CAST(Age AS INT) < 35) AND Nationality IN (SELECT Nationality FROM host WHERE TRY_CAST(Age AS INT) > 45); |
What are the ids of courses without prerequisites?
Schema:
- course(COUNT, JO, SUM, Stat, T1, course_id, credits, dept_name, title)
- prereq(...) | SELECT course_id FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq); |
What are the maximum and minimum resolution of songs whose duration is 3 minutes?
Schema:
- files(COUNT, duration, f_id, formats)
- song(COUNT, M, art, artist_name, engl, f_id, genre_is, languages, rat, rating, releasedate, resolution, ... (1 more)) | SELECT MAX(T2.resolution) AS max_resolution, MIN(T2.resolution) AS min_resolution FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.duration LIKE '3:%'; |
Show the years and the official names of the host cities of competitions.?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more))
- farm_competition(Hosts, Theme, Year) | SELECT T2."Year", T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID; |
Who was the director of the movie Joy from 2015 ?
Schema:
- director(Afghan, name, nationality)
- directed_by(...)
- movie(Budget_million, Director, Find, Gross_worldwide, T1, Title, Year, budget, release_year, title) | SELECT T2.name FROM director AS T2 JOIN directed_by AS T1 ON T2.did = T1.did JOIN movie AS T3 ON T3.mid = T1.msid WHERE T3.release_year = 2015 AND T3.title = 'Joy'; |
How many different statuses do cities have?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more)) | SELECT COUNT(DISTINCT Status) AS num_statuses FROM city; |
List the names of all distinct wines that have scores higher than 90.?
Schema:
- wine(Appelation, Cases, Grape, M, Name, Price, Score, Winery, Year, Z, w) | SELECT Name FROM wine WHERE Score > 90; |
Show year where a track with a seating at least 5000 opened and a track with seating no more than 4000 opened.?
Schema:
- track(Location, Name, Seat, Seating, T1, Year_Opened) | SELECT Year_Opened FROM track WHERE Seating BETWEEN 4000 AND 5000; |
Find the title of course that is provided by both Statistics and Psychology departments.?
Schema:
- course(COUNT, JO, SUM, Stat, T1, course_id, credits, dept_name, title) | SELECT DISTINCT T1.title FROM (SELECT title FROM course WHERE dept_name = 'Statistics') AS T1 JOIN (SELECT title FROM course WHERE dept_name = 'Psychology') AS T2 ON T1.title = T2.title; |
Find the total number of students in each department.?
Schema:
- student(COUNT, H, dept_name, name, tot_cred) | SELECT COUNT(*) AS num_students, dept_name FROM student GROUP BY dept_name; |
Find all members of "Bootup Baltimore" whose major is "600". Show the first name and last name.?
Schema:
- Club(ClubDesc, ClubLocation, ClubName, Enterpr, Gam, Hopk, Tenn)
- Member_of_club(...)
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age) | SELECT T3.Fname, T3.LName FROM Club AS T1 JOIN Member_of_club AS T2 ON T1.ClubID = T2.ClubID JOIN Student AS T3 ON T2.StuID = T3.StuID WHERE T1.ClubName = 'Bootup Baltimore' AND T3.Major = '600'; |
How many drivers did not participate in the races held in 2009?
Schema:
- results(...)
- races(date, name) | SELECT COUNT(DISTINCT driverId) AS num_drivers FROM results WHERE raceId NOT IN(SELECT raceId FROM races WHERE "year" = 2009); |
What are the products that have problems reported after 1986-11-13? Give me the product id and the count of problems reported after 1986-11-13.?
Schema:
- Problems(date_problem_reported, problem_id)
- Product(product_id, product_name) | SELECT COUNT(*) AS num_problems, T2.product_id FROM Problems AS T1 JOIN Product AS T2 ON T1.product_id = T2.product_id WHERE T1.date_problem_reported > DATE '1986-11-13' GROUP BY T2.product_id; |
What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks?
Schema:
- Album(Title)
- Track(Milliseconds, Name, UnitPrice)
- Genre(Name) | SELECT DISTINCT T1.Title FROM Album AS T1 JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId JOIN Genre AS T3 ON T2.GenreId = T3.GenreId WHERE T3.Name = 'Reggae' AND EXISTS (SELECT 1 FROM Track AS T2_sub JOIN Genre AS T3_sub ON T2_sub.GenreId = T3_sub.GenreId WHERE T3_sub.Name = 'Rock' AND T1.AlbumId = T2_sub.AlbumId); |
What are the first names of all professors who teach more than one class?
Schema:
- CLASS(CLASS_CODE, CLASS_ROOM, CLASS_SECTION, CRS_CODE, PROF_NUM)
- EMPLOYEE(EMP_DOB, EMP_FNAME, EMP_JOBCODE, EMP_LNAME) | SELECT T2.EMP_FNAME FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM GROUP BY T1.PROF_NUM, T2.EMP_FNAME HAVING COUNT(*) > 1; |
How many matches were played in 2013 or 2016?
Schema:
- matches_(COUNT, T1, loser_age, loser_name, minutes, tourney_name, winner_age, winner_hand, winner_name, winner_rank, winner_rank_points, year) | SELECT COUNT(*) AS num_matches FROM matches_ WHERE "year" = 2013 OR "year" = 2016; |
What the full names, ids of each employee and the name of the country they are in?
Schema:
- employees(COMMISSION_PCT, DEPARTMENT_ID, EMAIL, EMPLOYEE_ID, FIRST_NAME, HIRE_DATE, JOB_ID, LAST_NAME, M, MANAGER_ID, PHONE_NUMBER, SALARY, ... (12 more))
- departments(DEPARTMENT_NAME, Market)
- locations(COUNTRY_ID)
- countries(...) | SELECT T1.FIRST_NAME, T1.LAST_NAME, T1.EMPLOYEE_ID, T4.COUNTRY_NAME FROM employees AS T1 JOIN departments AS T2 ON T1.DEPARTMENT_ID = T2.DEPARTMENT_ID JOIN locations AS T3 ON T2.LOCATION_ID = T3.LOCATION_ID JOIN countries AS T4 ON T3.COUNTRY_ID = T4.COUNTRY_ID; |
How many different jobs are listed?
Schema:
- Person(M, age, city, eng, gender, job, name) | SELECT COUNT(DISTINCT job) AS num_jobs FROM Person; |
how many ACL papers by author?
Schema:
- venue(venueId, venueName)
- paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year)
- writes(...) | SELECT DISTINCT COUNT(T2.paperId) AS num_papers, T1.authorId FROM venue AS T3 JOIN paper AS T2 ON T3.venueId = T2.venueId JOIN writes AS T1 ON T1.paperId = T2.paperId WHERE T3.venueName = 'ACL' GROUP BY T1.authorId; |
How many different departments offer degrees?
Schema:
- Degree_Programs(degree_summary_name, department_id) | SELECT COUNT(DISTINCT department_id) AS num_departments FROM Degree_Programs; |
What are the teams with the most technicians?
Schema:
- technician(Age, COUNT, JO, Start, Starting_Year, T1, Team, name) | SELECT Team FROM technician WHERE Team IS NOT NULL GROUP BY Team ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
What are the different states that have students trying out?
Schema:
- College(M, cName, enr, state)
- Tryout(COUNT, EX, T1, cName, decision, pPos) | SELECT DISTINCT state FROM College AS T1 JOIN Tryout AS T2 ON T1.cName = T2.cName; |
What are the names of all songs in English?
Schema:
- song(COUNT, M, art, artist_name, engl, f_id, genre_is, languages, rat, rating, releasedate, resolution, ... (1 more)) | SELECT song_name FROM song WHERE languages = 'english'; |
What is the type and id of the organization that has the most research staff?
Schema:
- Organisations(...)
- Research_Staff(staff_details) | SELECT T1.organisation_type, T1.organisation_id FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_id, T1.organisation_type ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
What are the names of all employees who can fly both the Boeing 737-800 and the Airbus A340-300?
Schema:
- employee(Address, Age, Bdate, City, Fname, Lname, Name, Salary, Sex, eid, name, salary)
- certificate(eid)
- aircraft(Description, aid, d, distance, name) | SELECT DISTINCT T4.name FROM (SELECT T1.name FROM employee AS T1 JOIN certificate AS T2 ON T1.eid = T2.eid JOIN aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = 'Boeing 737-800') T4, (SELECT T1.name FROM employee AS T1 JOIN certificate AS T2 ON T1.eid = T2.eid JOIN aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = 'Airbus A340-300') AS T5 WHERE T4.name = T5.name; |
For the countries founded before 1930, what is the total number of distinct official languages?
Schema:
- country(Capital, Continent, Country_name, Engl, GNP, GovernmentForm, HeadOfState, IndepYear, LifeExpectancy, M, Name, Official_native_language, ... (4 more))
- countrylanguage(COUNT, CountryCode, Engl, Language) | SELECT COUNT(DISTINCT T2."Language") AS num_languages FROM country AS T1 JOIN countrylanguage AS T2 ON T1.Code = T2.CountryCode WHERE IndepYear < 1930 AND T2.IsOfficial = 'T'; |
What are all locations of train stations?
Schema:
- station(Annual_entry_exit, Annual_interchanges, COUNT, Location, MAX, Main_Services, Mounta, Name, Number_of_Platforms, city, id, lat, ... (4 more)) | SELECT DISTINCT Location FROM station; |
What are the names of the aircraft that the least people are certified to fly?
Schema:
- certificate(eid)
- aircraft(Description, aid, d, distance, name) | SELECT T2.name FROM certificate AS T1 JOIN aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid, T2.name ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
What are the names and year of joining for artists that do not have the country "United States"?
Schema:
- FROM(Country, Name, Year_Join) | SELECT Name, Year_Join FROM artist WHERE Country != 'United States'; |
What is the name of every city that has at least 15 stations and how many stations does it have?
Schema:
- station(Annual_entry_exit, Annual_interchanges, COUNT, Location, MAX, Main_Services, Mounta, Name, Number_of_Platforms, city, id, lat, ... (4 more)) | SELECT city, COUNT(*) AS num_stations FROM station WHERE city IS NOT NULL GROUP BY city HAVING COUNT(*) >= 15; |
Find the average age of students who are living in the dorm with the largest capacity.?
Schema:
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
- Lives_in(...)
- Dorm(dorm_name, gender, student_capacity) | SELECT AVG(T1.Age) AS avg_age FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT MAX(student_capacity) FROM Dorm); |
Show writers who have published a book with price more than 4000000.?
Schema:
- book(Ela, Issues, Title, Writer)
- publication(COUNT, Mak, Price, Publ, Publication_Date, Publisher, T1, abstract, citation_num, reference_num, title, year) | SELECT T1.Writer FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID WHERE T2.Price > 4000000; |
return me the number of researchers in " University of Michigan " .?
Schema:
- organization(continent, homepage, name)
- author(...) | SELECT COUNT(DISTINCT T1.name) AS num_researchers FROM organization AS T2 JOIN author AS T1 ON T2.oid = T1.oid WHERE T2.name = 'University of Michigan'; |
Show the distinct fate of missions that involve ships with nationality "United States"?
Schema:
- mission(...)
- ship(COUNT, DIST, JO, K, Name, Nationality, T1, Tonnage, Type, disposition_of_ship, name, tonnage) | SELECT DISTINCT T1.Fate FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID WHERE T2.Nationality = 'United States'; |
What are the mascots for schools with enrollments above the average?
Schema:
- School(County, Enrollment, Location, Mascot, School_name) | SELECT Mascot FROM School WHERE Enrollment > (SELECT AVG(Enrollment) FROM School); |
Find the balance of the checking account belonging to an owner whose name contains 'ee'.?
Schema:
- ACCOUNTS(name)
- CHECKING(balance) | SELECT T2.balance FROM ACCOUNTS AS T1 JOIN CHECKING AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%'; |
What is the id of the account with the most transactions?
Schema:
- Financial_Transactions(COUNT, F, SUM, account_id, invoice_number, transaction_amount, transaction_id, transaction_type) | SELECT account_id FROM Financial_Transactions WHERE account_id IS NOT NULL GROUP BY account_id ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1; |
Find the number of the products that have their color described as "red" and have a characteristic named "slow".?
Schema:
- Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more))
- Product_Characteristics(...)
- Characteristics(characteristic_name)
- Ref_Colors(color_description) | SELECT COUNT(*) AS num_products 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 = 'slow'; |
What are the first and last names of the employee with the earliest date of birth?
Schema:
- EMPLOYEE(EMP_DOB, EMP_FNAME, EMP_JOBCODE, EMP_LNAME) | SELECT EMP_FNAME, EMP_LNAME FROM EMPLOYEE ORDER BY EMP_DOB ASC NULLS LAST LIMIT 1; |
Show the number of cities in counties that have a population more than 20000.?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more))
- county_public_safety(COUNT, Case_burden, Crime_rate, Location, Name, Police_force, Police_officers, Population, T1) | SELECT COUNT(*) AS num_cities FROM city WHERE County_ID IN (SELECT County_ID FROM county_public_safety WHERE Population > 20000); |
Find the names of the clubs that have at least a member from the city with city code "HOU".?
Schema:
- Club(ClubDesc, ClubLocation, ClubName, Enterpr, Gam, Hopk, Tenn)
- Member_of_club(...)
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age) | SELECT DISTINCT T1.ClubName FROM Club AS T1 JOIN Member_of_club AS T2 ON T1.ClubID = T2.ClubID JOIN Student AS T3 ON T2.StuID = T3.StuID WHERE T3.city_code = 'HOU'; |
How many movies did " Shahab Hosseini " act in?
Schema:
- cast_(...)
- actor(Afghan, Aust, COUNT, Character, Chr, Duration, Kev, Name, age, birth_city, birth_year, first_name, ... (4 more))
- movie(Budget_million, Director, Find, Gross_worldwide, T1, Title, Year, budget, release_year, title) | SELECT COUNT(DISTINCT T2.title) AS num_movies FROM cast_ AS T3 JOIN actor AS T1 ON T3.aid = T1.aid JOIN movie AS T2 ON T2.mid = T3.msid WHERE T1.name = 'Shahab Hosseini'; |
What are all the different first names of the drivers who are in position as standing and won?
Schema:
- drivers(forename, nationality, surname)
- driverStandings(...) | SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverStandings AS T2 ON T1.driverId = T2.driverId WHERE T2."position" = 1 AND T2.wins = 1; |
What is the name of the youngest captain?
Schema:
- captain(COUNT, Class, INT, Name, Rank, TRY_CAST, age, capta, l) | SELECT Name FROM captain ORDER BY age ASC NULLS LAST LIMIT 1; |
How many pets are owned by students that have an age greater than 20?
Schema:
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
- Has_Pet(...) | SELECT COUNT(*) AS num_pets FROM Student AS T1 JOIN Has_Pet AS T2 ON T1.StuID = T2.StuID WHERE T1.Age > 20; |
List the names of buildings that have no company office.?
Schema:
- buildings(Height, Status, Stories, name)
- Office_locations(...) | SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.