question
stringlengths 43
589
| query
stringlengths 19
598
|
|---|---|
List the asset id, details, make and model for every asset.?
Schema:
- Assets(asset_acquired_date, asset_details, asset_disposed_date, asset_id, asset_make, asset_model)
|
SELECT asset_id, asset_details, asset_make, asset_model FROM Assets;
|
Find all airlines that have fewer than 200 flights.?
Schema:
- airlines(Abbreviation, Airline, COUNT, Country, active, country, name)
- flights(DestAirport, FlightNo, SourceAirport)
|
SELECT T1.Airline FROM airlines AS T1 JOIN flights AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING COUNT(*) < 200;
|
Find out 5 customers who most recently purchased something. List customers' first and last name.?
Schema:
- customers(Mart, city, company, country, email, first_name, last_name, phone, state)
- invoices(billing_city, billing_country, billing_state, total)
|
SELECT T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY T2.invoice_date DESC NULLS LAST LIMIT 5;
|
Find the name and capacity of products with price greater than 700 (in USD).?
Schema:
- Catalog_Contents(capacity, catalog_entry_name, height, next_entry_id, price_in_dollars, price_in_euros, product_stock_number)
|
SELECT catalog_entry_name, capacity FROM Catalog_Contents WHERE price_in_dollars > 700;
|
List the names of hosts who did not serve as a host of any party in our record.?
Schema:
- host(Age, COUNT, Name, Nationality)
- party_host(...)
|
SELECT Name FROM host WHERE Host_ID NOT IN (SELECT Host_ID FROM party_host);
|
Give me the best french restaurant in san francisco ?
Schema:
- restaurant(...)
- location(...)
|
SELECT T2.house_number, T1.name FROM restaurant AS T1 JOIN location AS T2 ON T1.id = T2.restaurant_id WHERE T2.city_name = 'san francisco' AND T1.food_type = 'french' AND T1.rating = (SELECT MAX(T1.rating) FROM restaurant AS T1 JOIN location AS T2 ON T1.id = T2.restaurant_id WHERE T2.city_name = 'san francisco' AND T1.food_type = 'french');
|
List the research staff details, and order in ascending order.?
Schema:
- Research_Staff(staff_details)
|
SELECT staff_details FROM Research_Staff ORDER BY staff_details ASC NULLS LAST;
|
Return the name of the category to which the film 'HUNGER ROOF' belongs.?
Schema:
- category(...)
- film_category(...)
- film(COUNT, Directed_by, Director, Gross_in_dollar, JO, LENGTH, Studio, T1, Title, language_id, rating, rental_rate, ... (3 more))
|
SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF';
|
Which papers did the author "Olin Shivers" write? Give me the paper titles.?
Schema:
- Authors(fname, lname)
- Authorship(...)
- Papers(title)
|
SELECT T3.title FROM Authors AS T1 JOIN Authorship AS T2 ON T1.authID = T2.authID JOIN Papers AS T3 ON T2.paperID = T3.paperID WHERE T1.fname = 'Olin' AND T1.lname = 'Shivers';
|
What is the name of the department that has the largest number of students enrolled?
Schema:
- CLASS(CLASS_CODE, CLASS_ROOM, CLASS_SECTION, CRS_CODE, PROF_NUM)
- ENROLL(...)
- COURSE(C, CRS_CODE, CRS_CREDIT, CRS_DESCRIPTION, DEPT_CODE)
- DEPARTMENT(Account, DEPT_ADDRESS, DEPT_NAME, H, SCHOOL_CODE)
|
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, T4.DEPT_NAME ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
|
Return the themes of farm competitions, sorted by year ascending.?
Schema:
- farm_competition(Hosts, Theme, Year)
|
SELECT Theme FROM farm_competition ORDER BY "Year" ASC NULLS LAST;
|
Find the name and account balance of the customer whose name includes the letter ‘a’.?
Schema:
- customer(COUNT, T1, acc_bal, acc_type, active, check, credit_score, cust_name, no_of_loans, sav, state, store_id)
|
SELECT cust_name, acc_bal FROM customer WHERE cust_name LIKE '%a%';
|
Give me a list of all the distinct building descriptions.?
Schema:
- Apartment_Buildings(building_address, building_description, building_full_name, building_manager, building_phone, building_short_name)
|
SELECT DISTINCT building_description FROM Apartment_Buildings;
|
Show details of all investors if they make any transaction with share count greater than 100.?
Schema:
- Investors(Investor_details)
- Transactions(COUNT, DOUBLE, TRY_CAST, amount_of_transaction, date_of_transaction, investor_id, share_count, transaction_id, transaction_type_code)
|
SELECT T1.Investor_details FROM Investors AS T1 JOIN Transactions AS T2 ON T1.investor_id = T2.investor_id WHERE TRY_CAST(T2.share_count AS DOUBLE) > 100;
|
Which customers have ever canceled the purchase of the product "food" (the item status is "Cancel")?
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))
- Orders(customer_id, date_order_placed, order_id)
- 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 T1.customer_name FROM Customers AS T1 JOIN 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 T3.order_item_status = 'Cancel' AND T4.product_name = 'food' GROUP BY T1.customer_id, T1.customer_name HAVING COUNT(*) >= 1;
|
what is the lowest point of iowa?
Schema:
- highlow(M, highest_elevation, highest_point, lowest_elevation, lowest_point, state_name)
|
SELECT lowest_point FROM highlow WHERE state_name = 'iowa';
|
Find the users who have given tips on Pet Groomers?
Schema:
- category(...)
- business(business_id, city, full_address, name, rating, review_count, state)
- tip(month, text)
- user_(name)
|
SELECT T4.name FROM category AS T2 JOIN business AS T1 ON T2.business_id = T1.business_id JOIN tip AS T3 ON T3.business_id = T1.business_id JOIN user_ AS T4 ON T4.user_id = T3.user_id WHERE T2.category_name = 'Pet Groomers';
|
Find the first name of students who are living in the Smith Hall.?
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 T1.Fname 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.dorm_name = 'Smith Hall';
|
What are the ids for templates that are not used in any documents?
Schema:
- Templates(COUNT, M, Template_ID, Template_Type_Code, Version_Number)
- 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 Template_ID FROM Templates WHERE Template_ID NOT IN (SELECT Template_ID FROM Documents);
|
what are the high points of states surrounding mississippi?
Schema:
- highlow(M, highest_elevation, highest_point, lowest_elevation, lowest_point, state_name)
- border_info(T1, border, state_name)
|
SELECT highest_point FROM highlow WHERE state_name IN (SELECT border FROM border_info WHERE state_name = 'mississippi');
|
Which attraction type does the most tourist attractions belong to? Tell me its attraction type description and code.?
Schema:
- Ref_Attraction_Types(...)
- Tourist_Attractions(Al, COUNT, How_to_Get_There, Name, Opening_Hours, Rosal, T1, T3, Tour, Tourist_Attraction_ID, Tourist_Details, Tourist_ID, ... (2 more))
|
SELECT T1.Attraction_Type_Description, T2.Attraction_Type_Code FROM Ref_Attraction_Types AS T1 JOIN Tourist_Attractions AS T2 ON T1.Attraction_Type_Code = T2.Attraction_Type_Code GROUP BY T2.Attraction_Type_Code, T1.Attraction_Type_Description ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
|
Show names for all regions except for Denmark.?
Schema:
- region(Label, Region_code, Region_name)
|
SELECT Region_name FROM region WHERE Region_name != 'Denmark';
|
What are the names and locations of festivals?
Schema:
- festival_detail(Chair_Name, Festival_Name, Location, T1, Year)
|
SELECT Festival_Name, Location FROM festival_detail;
|
Find all the cities that have 2 to 4 parks.?
Schema:
- park(city, state)
|
SELECT city FROM park WHERE city IS NOT NULL GROUP BY city HAVING COUNT(*) BETWEEN 2 AND 4;
|
Show the name of drivers in descending order of age.?
Schema:
- driver(Age, Home_city, Name, Party)
|
SELECT Name FROM driver ORDER BY Age DESC NULLS LAST;
|
What is the name of every singer that does not have any song?
Schema:
- singer(Age, Birth_Year, COUNT, Citizenship, Country, Name, Net_Worth_Millions, Song_Name, Song_release_year, T1, s)
- song(COUNT, M, art, artist_name, engl, f_id, genre_is, languages, rat, rating, releasedate, resolution, ... (1 more))
|
SELECT Name FROM singer WHERE Singer_ID NOT IN (SELECT Singer_ID FROM song);
|
Give the total surface area covered by countries in Asia or Europe.?
Schema:
- country(Capital, Continent, Country_name, Engl, GNP, GovernmentForm, HeadOfState, IndepYear, LifeExpectancy, M, Name, Official_native_language, ... (4 more))
|
SELECT SUM(SurfaceArea) AS total_surface_area FROM country WHERE Continent = 'Asia' OR Continent = 'Europe';
|
Return the different classes of races.?
Schema:
- race(Class, Date, Name)
|
SELECT DISTINCT Class FROM race;
|
What are the different names and credit scores of customers who have taken a loan?
Schema:
- customer(COUNT, T1, acc_bal, acc_type, active, check, credit_score, cust_name, no_of_loans, sav, state, store_id)
- loan(...)
|
SELECT DISTINCT T1.cust_name, T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_ID = T2.cust_ID;
|
What is the ship with the largest amount of tonnage called?
Schema:
- ship(COUNT, DIST, JO, K, Name, Nationality, T1, Tonnage, Type, disposition_of_ship, name, tonnage)
|
SELECT Name FROM ship ORDER BY Tonnage DESC NULLS LAST LIMIT 1;
|
what is the biggest state?
Schema:
- state(M, area, aust, capital, country_name, density, population, population_per_square_km, rhode, state_name, wyom)
|
SELECT state_name FROM state WHERE area = (SELECT MAX(area) FROM state);
|
What is the headquarter of the company with the largest sales?
Schema:
- company(Bank, COUNT, Company, Headquarters, Industry, JO, Main_Industry, Market_Value, Name, Profits_in_Billion, Rank, Retail, ... (4 more))
|
SELECT Headquarters FROM company ORDER BY Sales_in_Billion DESC NULLS LAST LIMIT 1;
|
Which papers have "Stephanie Weirich" as an author?
Schema:
- Authors(fname, lname)
- Authorship(...)
- Papers(title)
|
SELECT T3.title FROM Authors AS T1 JOIN Authorship AS T2 ON T1.authID = T2.authID JOIN Papers AS T3 ON T2.paperID = T3.paperID WHERE T1.fname = 'Stephanie' AND T1.lname = 'Weirich';
|
What is the average, maximum, and minimum budget for all movies before 2000.?
Schema:
- movie(Budget_million, Director, Find, Gross_worldwide, T1, Title, Year, budget, release_year, title)
|
SELECT AVG(Budget_million) AS avg_budget, MAX(Budget_million) AS max_budget, MIN(Budget_million) AS min_budget FROM movie WHERE "Year" < 2000;
|
Find the names of districts where have both city mall and village store type stores.?
Schema:
- district(City_Area, City_Population, District_name, d)
- store(Type)
- store_district(...)
|
SELECT DISTINCT T1.District_name FROM district AS T1 WHERE EXISTS (SELECT 1 FROM store AS T2 JOIN store_district AS T3 ON T2.Store_ID = T3.Store_ID WHERE T1.District_ID = T3.District_ID AND T2.Type = 'City Mall') AND EXISTS (SELECT 1 FROM store AS T4 JOIN store_district AS T5 ON T4.Store_ID = T5.Store_ID WHERE T1.District_ID = T5.District_ID AND T4.Type = 'Village Store');
|
most common topics at NIPS 2015?
Schema:
- paperKeyphrase(...)
- keyphrase(...)
- paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year)
- venue(venueId, venueName)
|
SELECT DISTINCT COUNT(T3.paperId) AS num_papers, T1.keyphraseId FROM paperKeyphrase AS T2 JOIN keyphrase AS T1 ON T2.keyphraseId = T1.keyphraseId JOIN paper AS T3 ON T3.paperId = T2.paperId JOIN venue AS T4 ON T4.venueId = T3.venueId WHERE T3."year" = 2015 AND T4.venueName = 'NIPS' GROUP BY T1.keyphraseId ORDER BY num_papers DESC NULLS LAST;
|
What is the average weight of all players?
Schema:
- Player(HS, pName, weight, yCard)
|
SELECT AVG(weight) AS avg_weight FROM Player;
|
Which part has the least chargeable amount? List the part id and amount.?
Schema:
- Parts(chargeable_amount, part_id)
|
SELECT part_id, chargeable_amount FROM Parts ORDER BY chargeable_amount ASC NULLS LAST LIMIT 1;
|
List all students' first names and last names who majored in 600.?
Schema:
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
|
SELECT Fname, LName FROM Student WHERE Major = 600;
|
List all employees in the circulation history of the document with id 1. List the employee's name.?
Schema:
- Employees(COUNT, Date_of_Birth, Employee_ID, Employee_Name, Role_Code, employee_id, employee_name, role_code)
- Circulation_History(copy_number, document_id, draft_number, employee_id)
|
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
|
What are the names of representatives in descending order of votes?
Schema:
- election(Committee, Date, Delegate, District, Vote_Percent, Votes)
- representative(JO, Lifespan, Name, Party, State, T1)
|
SELECT T2.Name FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID ORDER BY Votes DESC NULLS LAST;
|
Find the name of tourney that has more than 10 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 tourney_name FROM matches_ WHERE tourney_name IS NOT NULL GROUP BY tourney_name HAVING COUNT(*) > 10;
|
Find all the reviews for all Pet Groomers with more than 100 reviews?
Schema:
- category(...)
- business(business_id, city, full_address, name, rating, review_count, state)
- review(i_id, rank, rating, text)
|
SELECT T3."text" FROM category AS T2 JOIN business AS T1 ON T2.business_id = T1.business_id JOIN review AS T3 ON T3.business_id = T1.business_id WHERE T1.review_count > 100 AND T2.category_name = 'Pet Groomers';
|
Which paper did Richard Ladner present at chi ?
Schema:
- venue(venueId, venueName)
- paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year)
- writes(...)
- author(...)
|
SELECT DISTINCT T3.paperId FROM venue AS T4 JOIN paper AS T3 ON T4.venueId = T3.venueId JOIN writes AS T2 ON T2.paperId = T3.paperId JOIN author AS T1 ON T2.authorId = T1.authorId WHERE T1.authorName = 'Richard Ladner' AND T4.venueName = 'chi';
|
Find the total hours of the projects that scientists named Michael Rogers or Carol Smith are assigned to.?
Schema:
- AssignedTo(Scientist)
- Projects(COUNT, Hours, Name, Project_Details, Project_ID, organ, organisation_id, project_details)
- Scientists(Name)
|
SELECT SUM(T2.Hours) AS total_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';
|
How many songs appear in studio albums?
Schema:
- Albums(COUNT, Label, Title)
- Tracklists(...)
- Songs(Title)
|
SELECT COUNT(DISTINCT T3.Title) AS num_songs FROM Albums AS T1 JOIN Tracklists AS T2 ON T1.AId = T2.AlbumId JOIN Songs AS T3 ON T2.SongId = T3.SongId WHERE T1.Type = 'Studio';
|
Find the average age of all students living in the each city.?
Schema:
- Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
|
SELECT AVG(Age) AS avg_age, city_code FROM Student GROUP BY city_code;
|
List the names of customers who have once canceled the purchase of the product "food" (the item status is "Cancel").?
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))
- Orders(customer_id, date_order_placed, order_id)
- 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 T1.customer_name FROM Customers AS T1 JOIN 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 T3.order_item_status = 'Cancel' AND T4.product_name = 'food' GROUP BY T1.customer_id, T1.customer_name HAVING COUNT(*) >= 1;
|
Find the name and email for the users who have more than one follower.?
Schema:
- user_profiles(email, followers, name, partitionid)
- follows(f1)
|
SELECT T1.name, T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1, T1.name, T1.email HAVING COUNT(*) > 1;
|
What are the ids of all songs that have higher resolution of the average resolution in the modern genre?
Schema:
- song(COUNT, M, art, artist_name, engl, f_id, genre_is, languages, rat, rating, releasedate, resolution, ... (1 more))
|
SELECT f_id FROM song WHERE resolution > (SELECT AVG(resolution) FROM song WHERE genre_is = 'modern');
|
What are the names and urls of images, sorted alphabetically?
Schema:
- Images(image_name, image_url)
|
SELECT image_name, image_url FROM Images ORDER BY image_name ASC NULLS LAST;
|
Show all role codes and the number of employees in each role.?
Schema:
- Employees(COUNT, Date_of_Birth, Employee_ID, Employee_Name, Role_Code, employee_id, employee_name, role_code)
|
SELECT Role_Code, COUNT(*) AS num_employees FROM Employees GROUP BY Role_Code;
|
Give me the names of customers who have placed orders between 2009-01-01 and 2010-01-01.?
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))
- Orders(customer_id, date_order_placed, order_id)
|
SELECT T1.customer_name FROM Customers AS T1 JOIN Orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= '2009-01-01 00:00:00' AND T2.date_order_placed <= '2010-01-01 23:59:59';
|
Find the name and building of the department with the highest budget.?
Schema:
- department(Budget_in_Billions, COUNT, Creation, Dname, F, Market, Mgr_start_date, budget, building, dept_name, name)
|
SELECT dept_name, building FROM department ORDER BY budget DESC NULLS LAST LIMIT 1;
|
List all player names who have an overall rating higher than the average.?
Schema:
- Player(HS, pName, weight, yCard)
- Player_Attributes(overall_rating, preferred_foot)
|
SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.overall_rating > (SELECT AVG(overall_rating) FROM Player_Attributes);
|
What are the names and average prices of products for manufacturers whose products cost on average 150 or more?
Schema:
- Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more))
- Manufacturers(Aust, Beij, Founder, Headquarter, I, M, Name, Revenue)
|
SELECT AVG(T1.Price) AS avg_price, T2.Name FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Name HAVING AVG(T1.Price) >= 150;
|
what datasets do papers at ACL use most ?
Schema:
- paperDataset(...)
- dataset(...)
- paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year)
- venue(venueId, venueName)
|
SELECT DISTINCT T1.datasetId FROM paperDataset AS T2 JOIN dataset AS T1 ON T2.datasetId = T1.datasetId JOIN paper AS T3 ON T3.paperId = T2.paperId JOIN venue AS T4 ON T4.venueId = T3.venueId WHERE T4.venueName = 'ACL';
|
Which types of policy are chosen by more than 2 customers? Give me the policy type codes.?
Schema:
- Policies(COUNT, Policy_Type_Code)
|
SELECT Policy_Type_Code FROM Policies WHERE Policy_Type_Code IS NOT NULL GROUP BY Policy_Type_Code HAVING COUNT(*) > 2;
|
What are the ids of stations that have latitude above 37.4 and never had bike availability below 7?
Schema:
- station(Annual_entry_exit, Annual_interchanges, COUNT, Location, MAX, Main_Services, Mounta, Name, Number_of_Platforms, city, id, lat, ... (4 more))
- status(...)
|
SELECT id FROM station WHERE lat > 37.4 AND id NOT IN (SELECT station_id FROM status WHERE station_id IS NOT NULL GROUP BY station_id HAVING MIN(bikes_available) < 7);
|
Who are the nominees who have been nominated more than two times?
Schema:
- musical(Award, COUNT, Name, Nom, Nominee, Result, T1)
|
SELECT Nominee FROM musical WHERE Nominee IS NOT NULL GROUP BY Nominee HAVING COUNT(*) > 2;
|
Which districts have at least two addresses?
Schema:
- address(address, district, phone, postal_code)
|
SELECT district FROM address WHERE district IS NOT NULL GROUP BY district HAVING COUNT(*) >= 2;
|
give me some restaurants good for arabic food on buchanan in san francisco ?
Schema:
- restaurant(...)
- location(...)
|
SELECT T2.house_number, T1.name FROM restaurant AS T1 JOIN location AS T2 ON T1.id = T2.restaurant_id WHERE T2.city_name = 'san francisco' AND T2.street_name = 'buchanan' AND T1.food_type = 'arabic' AND T1.rating > 2.5;
|
What are the entry names of catalog with the attribute possessed by most entries.?
Schema:
- Catalog_Contents(capacity, catalog_entry_name, height, next_entry_id, price_in_dollars, price_in_euros, product_stock_number)
- Catalog_Contents_Additional_Attributes(...)
|
SELECT T1.catalog_entry_name FROM Catalog_Contents AS T1 JOIN Catalog_Contents_Additional_Attributes AS T2 ON T1.catalog_entry_id = T2.catalog_entry_id WHERE T2.attribute_value = (SELECT attribute_value FROM Catalog_Contents_Additional_Attributes WHERE attribute_value IS NOT NULL GROUP BY attribute_value ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1);
|
Show the names of buildings except for those having an institution founded in 2003.?
Schema:
- building(Floors, Height_feet, Name, build)
- Institution(COUNT, Enrollment, Founded, Type)
|
SELECT T1.Name FROM building AS T1 LEFT JOIN Institution AS T2 ON T1.building_id = T2.building_id WHERE T2.Founded != 2003 OR T2.Founded IS NULL;
|
Count the number of stores.?
Schema:
- store(Type)
|
SELECT COUNT(*) AS num_stores FROM store;
|
Return the duration of the actor with the greatest age.?
Schema:
- actor(Afghan, Aust, COUNT, Character, Chr, Duration, Kev, Name, age, birth_city, birth_year, first_name, ... (4 more))
|
SELECT Duration FROM actor ORDER BY age DESC NULLS LAST LIMIT 1;
|
what is the size of the capital of texas?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more))
- state(M, area, aust, capital, country_name, density, population, population_per_square_km, rhode, state_name, wyom)
|
SELECT population FROM city WHERE city_name = (SELECT capital FROM state WHERE state_name = 'texas');
|
What is the average balance in checking accounts?
Schema:
- CHECKING(balance)
|
SELECT AVG(balance) AS avg_balance FROM CHECKING;
|
Show the status shared by cities with population bigger than 1500 and smaller than 500.?
Schema:
- city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more))
|
SELECT DISTINCT T1.Status FROM (SELECT Status FROM city WHERE Population > 1500) AS T1, (SELECT Status FROM city WHERE Population < 500) AS T2 WHERE T1.Status = T2.Status;
|
Find the total revenue for each manufacturer.?
Schema:
- Manufacturers(Aust, Beij, Founder, Headquarter, I, M, Name, Revenue)
|
SELECT SUM(Revenue) AS total_revenue, Name FROM Manufacturers GROUP BY Name;
|
What is the degree summary name that has the most number of students enrolled?
Schema:
- Degree_Programs(degree_summary_name, department_id)
- Student_Enrolment(...)
|
SELECT T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_summary_name ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
|
Tell me the number of dogs that have not received any treatment .?
Schema:
- Dogs(abandoned_yn, age, breed_code, date_arrived, date_departed, name, size_code, weight)
- Treatments(cost_of_treatment, date_of_treatment, dog_id, professional_id)
|
SELECT COUNT(*) AS num_dogs FROM Dogs WHERE dog_id NOT IN (SELECT dog_id FROM Treatments);
|
What is the number of countries with more than 2 car makers ?
Schema:
- countries(...)
- car_makers(...)
|
SELECT COUNT(*) AS num_countries FROM countries WHERE CountryId IN (SELECT CountryId FROM car_makers WHERE CountryId IS NOT NULL GROUP BY CountryId HAVING COUNT(*) > 2);
|
What are the names of conductors whose nationalities are not "USA"?
Schema:
- conductor(Age, Name, Nationality, Year_of_Work)
|
SELECT Name FROM conductor WHERE Nationality != 'USA';
|
List the names of mountains that do not have any climber.?
Schema:
- mountain(AVG, COUNT, Country, Height, JO, Name, Prominence, Range, T1, mck, mounta, mountain_altitude, ... (3 more))
- climber(Country, K, Name, Points)
|
SELECT Name FROM mountain WHERE Mountain_ID NOT IN (SELECT Mountain_ID FROM climber);
|
What is average salary of the players in the team named 'Boston Red Stockings' ?
Schema:
- salary(salary)
- team(Name)
|
SELECT AVG(T1.salary) AS avg_salary FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings';
|
How many different product types are there?
Schema:
- Products_for_Hire(daily_hire_cost, product_description, product_name, product_type_code)
|
SELECT COUNT(DISTINCT product_type_code) AS num_product_types FROM Products_for_Hire;
|
List all information in the item table.?
Schema:
- item(title)
|
SELECT * FROM item;
|
What are the names of the winner and loser who played in the longest match?
Schema:
- matches_(COUNT, T1, loser_age, loser_name, minutes, tourney_name, winner_age, winner_hand, winner_name, winner_rank, winner_rank_points, year)
|
SELECT winner_name, loser_name FROM matches_ ORDER BY minutes DESC NULLS LAST LIMIT 1;
|
What is the match id of the competition called "1994 FIFA World Cup qualification"?
Schema:
- match_(Competition, Date, Match_ID, Venue)
|
SELECT Match_ID FROM match_ WHERE Competition = '1994 FIFA World Cup qualification';
|
For each bed type, find the average room price.?
Schema:
- Rooms(K, RoomId, basePrice, bedType, beds, decor, maxOccupancy, roomName)
|
SELECT bedType, AVG(basePrice) AS avg_room_price FROM Rooms GROUP BY bedType;
|
What activities do we have?
Schema:
- Activity(activity_name)
|
SELECT activity_name FROM Activity;
|
Find the total claimed amount of all the claims.?
Schema:
- Claims(Amount_Claimed, Amount_Settled, Date_Claim_Made, Date_Claim_Settled)
|
SELECT SUM(Amount_Claimed) AS total_claimed_amount FROM Claims;
|
What is the id, first name, and last name of the driver who was in the first position for laptime at least twice?
Schema:
- drivers(forename, nationality, surname)
- lapTimes(...)
|
SELECT T1.driverId, T1.forename, T1.surname FROM drivers AS T1 JOIN lapTimes AS T2 ON T1.driverId = T2.driverId WHERE "position" = '1' GROUP BY T1.driverId, T1.forename, T1.surname HAVING COUNT(*) >= 2;
|
What is the first name, last name, and phone of the customer with account name 162?
Schema:
- Accounts(Account_Details, Account_ID, Statement_ID, account_id, account_name, customer_id, date_account_opened, other_account_details)
- 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 T2.customer_first_name, T2.customer_last_name, T2.customer_phone FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = '162';
|
What are the unique types of player positions in the tryout?
Schema:
- Tryout(COUNT, EX, T1, cName, decision, pPos)
|
SELECT COUNT(DISTINCT pPos) AS num_positions FROM Tryout;
|
Return the maximum enrollment across all schools.?
Schema:
- university(Affiliation, Enrollment, Founded, Location, Nickname, Primary_conference, School)
|
SELECT MAX(Enrollment) AS max_enrollment FROM university;
|
How many orchestras does each record company manage?
Schema:
- orchestra(COUNT, Major_Record_Format, Record_Company, Year_of_Founded)
|
SELECT Record_Company, COUNT(*) AS num_orchestras FROM orchestra GROUP BY Record_Company;
|
Show all allergies with type food.?
Schema:
- Allergy_Type(Allergy, AllergyType, COUNT)
|
SELECT DISTINCT Allergy FROM Allergy_Type WHERE AllergyType = 'food';
|
Find the payment method that is used most frequently.?
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 payment_method FROM Customers WHERE payment_method IS NOT NULL GROUP BY payment_method ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
|
In which year did the most recent crime happen?
Schema:
- perpetrator(Country, Date, Injured, Killed, Location, Year)
|
SELECT MAX("Year") AS max_year FROM perpetrator;
|
Find the number of departments in each school.?
Schema:
- DEPARTMENT(Account, DEPT_ADDRESS, DEPT_NAME, H, SCHOOL_CODE)
|
SELECT COUNT(DISTINCT DEPT_NAME) AS num_departments, SCHOOL_CODE FROM DEPARTMENT GROUP BY SCHOOL_CODE;
|
What are the first and last names of all customers who lived in Lockmanfurt?
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))
- Addresses(address_content, city, country, line_1, line_1_number_building, line_2, state_province_county, town_city, zip_postcode)
|
SELECT T1.first_name, T1.last_name FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T2.city = 'Lockmanfurt';
|
how many places for chinese are there in the bay area ?
Schema:
- restaurant(...)
- geographic(...)
|
SELECT COUNT(*) AS num_places FROM restaurant AS T1 JOIN geographic AS T2 ON T1.city_name = T2.city_name WHERE T2.region = 'bay area' AND T1.food_type = 'chinese';
|
Return the average, maximum, and total revenues across all manufacturers.?
Schema:
- Manufacturers(Aust, Beij, Founder, Headquarter, I, M, Name, Revenue)
|
SELECT AVG(Revenue) AS avg_revenue, MAX(Revenue) AS max_revenue, SUM(Revenue) AS total_revenue FROM Manufacturers;
|
What is the name of the department with an instructure who has a name like 'Soisalon'?
Schema:
- instructor(AVG, M, So, Stat, dept_name, name, salary)
|
SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%';
|
List the total points of gymnasts in descending order of floor exercise points.?
Schema:
- gymnast(Floor_Exercise_Points, Horizontal_Bar_Points)
|
SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC NULLS LAST;
|
List the countries having more than 4 addresses listed.?
Schema:
- Addresses(address_content, city, country, line_1, line_1_number_building, line_2, state_province_county, town_city, zip_postcode)
|
SELECT country FROM Addresses WHERE country IS NOT NULL GROUP BY country HAVING COUNT(address_id) > 4;
|
Show different locations and the number of performances at each location.?
Schema:
- performance(Attendance, COUNT, Date, Location, T1)
|
SELECT Location, COUNT(*) AS num_performances FROM performance GROUP BY Location;
|
Find the entry name of the catalog with the highest price (in USD).?
Schema:
- Catalog_Contents(capacity, catalog_entry_name, height, next_entry_id, price_in_dollars, price_in_euros, product_stock_number)
|
SELECT catalog_entry_name FROM Catalog_Contents ORDER BY price_in_dollars DESC NULLS LAST LIMIT 1;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.