question
stringlengths
43
589
query
stringlengths
19
598
Which engineer has visited the most times? Show the engineer id, first name and last name.? Schema: - Maintenance_Engineers(COUNT, T1, engineer_id, first_name, last_name)
SELECT T1.engineer_id, T1.first_name, T1.last_name FROM Maintenance_Engineers AS T1, Engineer_Visits AS T2 GROUP BY T1.engineer_id, T1.first_name, T1.last_name ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
How many milliseconds long is Fast As a Shark? Schema: - tracks(composer, milliseconds, name, unit_price)
SELECT milliseconds FROM tracks WHERE name = 'Fast As a Shark';
Find the name and id of the team that won the most times in 2008 postseason.? Schema: - postseason(ties) - team(Name)
SELECT T2.name, T1.team_id_winner FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T1."year" = 2008 GROUP BY T2.name, T1.team_id_winner ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
How many people are under 40 for each gender? Schema: - Person(M, age, city, eng, gender, job, name)
SELECT COUNT(*) AS num_people, gender FROM Person WHERE age < 40 GROUP BY gender;
Find all the order items whose product id is 11. What are the order item ids? Schema: - Order_Items(COUNT, DOUBLE, INT, TRY_CAST, order_id, order_item_id, order_quantity, product_id, product_quantity)
SELECT order_item_id FROM Order_Items WHERE product_id = 11;
What is the number of car models created by the car maker American Motor Company? Schema: - car_makers(...) - model_list(Maker, Model)
SELECT COUNT(*) AS num_models FROM car_makers AS T1 JOIN model_list AS T2 ON T1.Id = T2.Maker WHERE T1.FullName = 'American Motor Company';
Return the number of airlines in the USA.? Schema: - airlines(Abbreviation, Airline, COUNT, Country, active, country, name)
SELECT COUNT(*) AS num_airlines FROM airlines WHERE Country = 'USA';
What are the names of products produced by both Creative Labs and Sony? 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 T1.Name FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code WHERE T2.Name = 'Creative Labs' AND EXISTS (SELECT 1 FROM Products AS T3 JOIN Manufacturers AS T4 ON T3.Manufacturer = T4.Code WHERE T3.Name = 'Sony' AND T1.Name = T3.Name);
What are the countries having at least one car maker? List name and id.? Schema: - countries(...) - car_makers(...)
SELECT T1.CountryName, T1.CountryId FROM countries AS T1 JOIN car_makers AS T2 ON T1.CountryId = T2.CountryId GROUP BY T1.CountryId, T1.CountryName HAVING COUNT(*) >= 1;
what state has the largest city? Schema: - city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more))
SELECT state_name FROM city WHERE population = (SELECT MAX(population) FROM city);
Find the maximum and minimum monthly rental for all student addresses.? Schema: - Student_Addresses(monthly_rental)
SELECT MAX(monthly_rental) AS max_monthly_rental, MIN(monthly_rental) AS min_monthly_rental FROM Student_Addresses;
Count the number of captains younger than 50 of each rank.? Schema: - captain(COUNT, Class, INT, Name, Rank, TRY_CAST, age, capta, l)
SELECT COUNT(*) AS num_captains, "Rank" FROM captain WHERE TRY_CAST(age AS INT) < 50 GROUP BY "Rank";
How many papers are presented in nature communications 2015 ? 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 T1."year" = 2015 AND T2.venueName = 'nature communications';
Find the names of schools that have some players in the mid position but not in the goalie position.? Schema: - Tryout(COUNT, EX, T1, cName, decision, pPos)
SELECT cName FROM Tryout WHERE pPos = 'mid' AND cName NOT IN (SELECT cName FROM Tryout WHERE pPos = 'goalie');
Count the number of departments which offer courses.? Schema: - course(COUNT, JO, SUM, Stat, T1, course_id, credits, dept_name, title)
SELECT COUNT(DISTINCT dept_name) AS num_departments FROM course;
Show the names and ids of tourist attractions that are visited at most once.? Schema: - Tourist_Attractions(Al, COUNT, How_to_Get_There, Name, Opening_Hours, Rosal, T1, T3, Tour, Tourist_Attraction_ID, Tourist_Details, Tourist_ID, ... (2 more)) - Visits(Visit_Date)
SELECT T1.Name, T1.Tourist_Attraction_ID FROM Tourist_Attractions AS T1 JOIN Visits AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID GROUP BY T2.Tourist_Attraction_ID, T1.Name, T1.Tourist_Attraction_ID HAVING COUNT(*) <= 1;
What are the first names and last names of all the guests? Schema: - Guests(date_of_birth, gender_code, guest_first_name, guest_last_name)
SELECT guest_first_name, guest_last_name FROM Guests;
What is the transaction type that has processed the greatest total amount in transactions? Schema: - Financial_Transactions(COUNT, F, SUM, account_id, invoice_number, transaction_amount, transaction_id, transaction_type)
SELECT transaction_type FROM Financial_Transactions WHERE transaction_type IS NOT NULL GROUP BY transaction_type ORDER BY SUM(transaction_amount) DESC NULLS LAST LIMIT 1;
Show the title and publication dates of books.? Schema: - book(Ela, Issues, Title, Writer) - publication(COUNT, Mak, Price, Publ, Publication_Date, Publisher, T1, abstract, citation_num, reference_num, title, year)
SELECT T1.Title, T2.Publication_Date FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID;
Show details of all visitors.? Schema: - Visitors(Tourist_Details)
SELECT Tourist_Details FROM Visitors;
Return the description of the product called "Chocolate".? Schema: - Products(COUNT, Code, Din, Manufacturer, Name, Price, Product_Name, Product_Price, Product_Type_Code, T1, Trad, cum, ... (11 more))
SELECT product_description FROM Products WHERE product_name = 'Chocolate';
What are the official languages of the countries of players from Maryland or Duke college? Schema: - country(Capital, Continent, Country_name, Engl, GNP, GovernmentForm, HeadOfState, IndepYear, LifeExpectancy, M, Name, Official_native_language, ... (4 more)) - match_season(COUNT, College, Draft_Class, Draft_Pick_Number, JO, Player, Position, T1, Team)
SELECT T1.Official_native_language FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.College = 'Maryland' OR T2.College = 'Duke';
Show the number of transactions for different investors.? Schema: - Transactions(COUNT, DOUBLE, TRY_CAST, amount_of_transaction, date_of_transaction, investor_id, share_count, transaction_id, transaction_type_code)
SELECT investor_id, COUNT(*) AS num_transactions FROM Transactions GROUP BY investor_id;
What are the most common types of interactions between enzymes and medicine, and how many types are there? Schema: - medicine_enzyme_interaction(interaction_type)
SELECT interaction_type, COUNT(*) AS num_interactions FROM medicine_enzyme_interaction WHERE interaction_type IS NOT NULL GROUP BY interaction_type ORDER BY num_interactions DESC NULLS LAST LIMIT 1;
What are the first names and last names of the students that minor in the department with DNO 140.? Schema: - Minor_in(...) - Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
SELECT T2.Fname, T2.LName FROM Minor_in AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.DNO = 140;
what is the area of the smallest state? Schema: - state(M, area, aust, capital, country_name, density, population, population_per_square_km, rhode, state_name, wyom)
SELECT area FROM state WHERE area = (SELECT MIN(area) FROM state);
Find the first names and offices of all instructors who have taught some course and also find the course description.? Schema: - CLASS(CLASS_CODE, CLASS_ROOM, CLASS_SECTION, CRS_CODE, PROF_NUM) - EMPLOYEE(EMP_DOB, EMP_FNAME, EMP_JOBCODE, EMP_LNAME) - COURSE(C, CRS_CODE, CRS_CREDIT, CRS_DESCRIPTION, DEPT_CODE) - PROFESSOR(DEPT_CODE, PROF_HIGH_DEGREE)
SELECT T2.EMP_FNAME, T4.PROF_OFFICE, T3.CRS_DESCRIPTION FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM;
What is the average age of the visitors whose membership level is not higher than 4? Schema: - visitor(Age, Level_of_membership, Name)
SELECT AVG(Age) AS avg_age FROM visitor WHERE Level_of_membership <= 4;
Show ids for all the male faculty.? Schema: - Faculty(Building, COUNT, FacID, Fname, LName, Lname, Phone, Pr, Rank, Room, Sex)
SELECT FacID FROM Faculty WHERE Sex = 'M';
what state has the most people? 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);
Give the mean GNP and total population of nations which are considered 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';
What are the id of each employee and the number of document destruction authorised by that employee? Schema: - Documents_to_be_Destroyed(Destroyed_by_Employee_ID, Destruction_Authorised_by_Employee_ID)
SELECT Destruction_Authorised_by_Employee_ID, COUNT(*) AS num_documents FROM Documents_to_be_Destroyed GROUP BY Destruction_Authorised_by_Employee_ID;
What are the names of all aicrafts that have never won any match? Schema: - aircraft(Description, aid, d, distance, name) - match_(Competition, Date, Match_ID, Venue)
SELECT Aircraft FROM aircraft WHERE Aircraft_ID NOT IN (SELECT Winning_Aircraft FROM match_);
What are the names of all reviewers that have given 3 or 4 stars for reviews? Schema: - Rating(Rat, mID, rID, stars) - Reviewer(Lew, name, rID)
SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars IN (3, 4) GROUP BY T2.name HAVING COUNT(DISTINCT T1.stars) = 2;
Find the name of accounts whose checking balance is below the average checking balance.? Schema: - ACCOUNTS(name) - CHECKING(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);
What is the minimum, average, and maximum distance of all aircrafts.? Schema: - aircraft(Description, aid, d, distance, name)
SELECT MIN(distance) AS min_distance, AVG(distance) AS avg_distance, MAX(distance) AS max_distance FROM aircraft;
return me the paper by " H. V. Jagadish " with more than 200 citations .? Schema: - writes(...) - author(...) - publication(COUNT, Mak, Price, Publ, Publication_Date, Publisher, T1, abstract, citation_num, reference_num, title, year)
SELECT T3.title FROM writes AS T2 JOIN author AS T1 ON T2.aid = T1.aid JOIN publication AS T3 ON T2.pid = T3.pid WHERE T1.name = 'H. V. Jagadish' AND T3.citation_num > 200;
What ranks do we have for faculty? Schema: - Faculty(Building, COUNT, FacID, Fname, LName, Lname, Phone, Pr, Rank, Room, Sex)
SELECT DISTINCT "Rank" FROM Faculty;
papers that used Question Answering? Schema: - paperKeyphrase(...) - keyphrase(...) - paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year)
SELECT DISTINCT T3.paperId FROM paperKeyphrase AS T2 JOIN keyphrase AS T1 ON T2.keyphraseId = T1.keyphraseId JOIN paper AS T3 ON T3.paperId = T2.paperId WHERE T1.keyphraseName = 'Question Answering';
Return the names of all counties sorted by population in ascending order.? Schema: - county(County_name, Population, Zip_code)
SELECT County_name FROM county ORDER BY Population ASC NULLS LAST;
Return the characters and durations for each actor.? Schema: - actor(Afghan, Aust, COUNT, Character, Chr, Duration, Kev, Name, age, birth_city, birth_year, first_name, ... (4 more))
SELECT "Character", Duration FROM actor;
What are the names of people in ascending order of height? Schema: - people(Age, Birth_Date, Birth_Place, COUNT, Country, Date_of_Birth, Height, Hometown, Is_Male, Name, Nationality, Party, ... (3 more))
SELECT Name FROM people ORDER BY Height ASC NULLS LAST;
Find the first and last name of all the teachers that teach EVELINA BROMLEY.? Schema: - list(COUNT, Classroom, FirstName, Grade, LastName) - teachers(Classroom, FirstName, LastName)
SELECT T2.FirstName, T2.LastName FROM list AS T1 JOIN teachers AS T2 ON T1.Classroom = T2.Classroom WHERE T1.FirstName = 'EVELINA' AND T1.LastName = 'BROMLEY';
Find courses that ran in Fall 2009 but not in Spring 2010.? Schema: - section(COUNT, JO, Spr, T1, course_id, semester, year)
SELECT course_id FROM section WHERE semester = 'Fall' AND "year" = 2009 AND course_id NOT IN (SELECT course_id FROM section WHERE semester = 'Spring' AND "year" = 2010);
how many citizens does the biggest city have in the usa? Schema: - city(COUNT, City, District, GDP, M, Name, Official_Name, Population, Regional_Population, SUM, Status, T1, ... (10 more))
SELECT population FROM city WHERE country_name = 'united states' AND population = (SELECT MAX(population) FROM city WHERE country_name = 'united states');
What are the title, id, and description of the movie with the greatest number of actors? Schema: - film_actor(...) - film(COUNT, Directed_by, Director, Gross_in_dollar, JO, LENGTH, Studio, T1, Title, language_id, rating, rental_rate, ... (3 more))
SELECT T2.title, T2.film_id, T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.title, T2.film_id, T2.description ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
what are all the rivers in illinois? Schema: - river(COUNT, DIST, LENGTH, M, country_name, illino, m, river_name, traverse)
SELECT river_name FROM river WHERE traverse = 'illinois';
Find the id and city of the student address with the highest average monthly rental.? Schema: - Addresses(address_content, city, country, line_1, line_1_number_building, line_2, state_province_county, town_city, zip_postcode) - Student_Addresses(monthly_rental)
SELECT T2.address_id, T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id, T1.city ORDER BY AVG(monthly_rental) DESC NULLS LAST LIMIT 1;
What are the names of customers who never made an order.? 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)
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);
How many regions were affected by each storm? Schema: - storm(Damage_millions_USD, Dates_active, Name, Number_Deaths) - affected_region(Region_id)
SELECT T1.Name, COUNT(*) AS num_regions FROM storm AS T1 JOIN affected_region AS T2 ON T1.Storm_ID = T2.Storm_ID GROUP BY T1.Storm_ID, T1.Name;
What are the different cities where people live? Schema: - Addresses(address_content, city, country, line_1, line_1_number_building, line_2, state_province_county, town_city, zip_postcode) - People_Addresses(...)
SELECT DISTINCT T1.city FROM Addresses AS T1 JOIN People_Addresses AS T2 ON T1.address_id = T2.address_id;
Find the description and credit for the course QM-261? Schema: - COURSE(C, CRS_CODE, CRS_CREDIT, CRS_DESCRIPTION, DEPT_CODE)
SELECT CRS_CREDIT, CRS_DESCRIPTION FROM COURSE WHERE CRS_CODE = 'QM-261';
Give all information regarding instructors, in order of salary from least to greatest.? Schema: - instructor(AVG, M, So, Stat, dept_name, name, salary)
SELECT * FROM instructor ORDER BY salary ASC NULLS LAST;
How many allergies are there? Schema: - Allergy_Type(Allergy, AllergyType, COUNT)
SELECT COUNT(DISTINCT Allergy) AS num_allergies FROM Allergy_Type;
Find the countries that have never participated in any competition with Friendly type.? Schema: - competition(COUNT, Competition_type, Country, T1, Year)
SELECT DISTINCT Country FROM competition WHERE Country NOT IN (SELECT Country FROM competition WHERE Competition_type = 'Friendly');
What is the document id with 1 to 2 paragraphs? Schema: - Paragraphs(COUNT, Document_ID, Other_Details, Paragraph_Text, T1)
SELECT Document_ID FROM Paragraphs WHERE Document_ID IS NOT NULL GROUP BY Document_ID HAVING COUNT(*) BETWEEN 1 AND 2;
Find all movies directed by " Steven Spielberg " after 2006? Schema: - director(Afghan, name, nationality) - directed_by(...) - movie(Budget_million, Director, Find, Gross_worldwide, T1, Title, Year, budget, release_year, title)
SELECT T3.title FROM director AS T2 JOIN directed_by AS T1 ON T2.did = T1.did JOIN movie AS T3 ON T3.mid = T1.msid WHERE T2.name = 'Steven Spielberg' AND T3.release_year > 2006;
Which district has both stores with less than 3000 products and stores with more than 10000 products? Schema: - shop(Address, District, INT, Location, Manager_name, Name, Number_products, Open_Year, Score, Shop_ID, Shop_Name, T1, ... (1 more))
SELECT DISTINCT T1.District FROM shop AS T1 JOIN shop AS T2 ON T1.District = T2.District WHERE T1.Number_products < 3000 AND T2.Number_products > 10000;
List the name of ships in ascending order of tonnage.? Schema: - ship(COUNT, DIST, JO, K, Name, Nationality, T1, Tonnage, Type, disposition_of_ship, name, tonnage)
SELECT Name FROM ship ORDER BY Tonnage ASC NULLS LAST;
What is the total share (in percent) of all the channels owned by CCTV? Schema: - channel(Name, Owner, Rating_in_percent, Share_in_percent)
SELECT SUM(Share_in_percent) AS total_share FROM channel WHERE Owner = 'CCTV';
How many paper does Christopher D. Manning have ? Schema: - writes(...) - author(...)
SELECT DISTINCT COUNT(DISTINCT T2.paperId) AS num_papers FROM writes AS T2 JOIN author AS T1 ON T2.authorId = T1.authorId WHERE T1.authorName = 'Christopher D. Manning';
how many Parsing papers did acl 2012 have ? Schema: - paperKeyphrase(...) - keyphrase(...) - paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year) - venue(venueId, venueName)
SELECT DISTINCT T3.paperId 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 T1.keyphraseName = 'Parsing' AND T3."year" = 2012 AND T4.venueName = 'acl';
Which student's age is older than 18 and is majoring in 600? List each student's first and last name.? Schema: - Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
SELECT Fname, LName FROM Student WHERE Age > 18 AND Major = 600;
Return the money rank of the player with the greatest earnings.? Schema: - poker_player(Best_Finish, Earnings, Final_Table_Made, Money_Rank)
SELECT Money_Rank FROM poker_player ORDER BY Earnings DESC NULLS LAST LIMIT 1;
Show the apartment numbers, start dates, and end dates of all the apartment bookings.? 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 T2.apt_number, T1.booking_start_date, T1.booking_end_date FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id;
Find the first names and last names of the authors whose institution affiliation is "University of Oxford".? Schema: - Authors(fname, lname) - Authorship(...) - Inst(...)
SELECT DISTINCT T1.fname, T1.lname FROM Authors AS T1 JOIN Authorship AS T2 ON T1.authID = T2.authID JOIN Inst AS T3 ON T2.instID = T3.instID WHERE T3.name = 'University of Oxford';
What are the names of departments either in division AS, or in division EN and in building NEB? Schema: - Department(Building, COUNT, DNO, DName, DPhone, DepartmentID, Division, FacID, Head, LName, Room, T2)
SELECT DISTINCT DName FROM (SELECT DName FROM Department WHERE Division = 'AS' UNION ALL SELECT DName FROM Department WHERE Division = 'EN' AND Building = 'NEB');
where can i find a restaurant in the bay area ? Schema: - location(...) - restaurant(...) - geographic(...)
SELECT T2.house_number, T1.name FROM location AS T2 JOIN restaurant AS T1 ON T1.id = T2.restaurant_id WHERE T1.city_name IN (SELECT city_name FROM geographic WHERE region = 'bay area');
What are the distinct types of the companies that have operated any flights with velocity less than 200? Schema: - operate_company(Group_Equity_Shareholding, Type) - flight(Altitude, COUNT, Date, Pilot, Vehicle_Flight_number, Velocity, arrival_date, departure_date, destination, distance, flno, origin, ... (1 more))
SELECT DISTINCT T1.Type FROM operate_company AS T1 JOIN flight AS T2 ON T1.id = T2.company_id WHERE T2.Velocity < 200;
Show customer ids who don't have an account.? 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)) - Accounts(Account_Details, Account_ID, Statement_ID, account_id, account_name, customer_id, date_account_opened, other_account_details)
SELECT Customers.customer_id FROM Customers LEFT JOIN Accounts ON Customers.customer_id = Accounts.customer_id WHERE Accounts.customer_id IS NULL;
How many services has each resident requested? List the resident id, details, and the count in descending order of the count.? Schema: - Residents(M, date_moved_in, last_day_moved_in, other_details) - Residents_Services(...)
SELECT T1.resident_id, T1.other_details, COUNT(*) AS num_services FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id = T2.resident_id GROUP BY T1.resident_id, T1.other_details ORDER BY num_services DESC NULLS LAST;
For each movie that received more than 3 reviews, what is the average rating? Schema: - Rating(Rat, mID, rID, stars)
SELECT mID, AVG(stars) AS avg_rating FROM Rating WHERE mID IS NOT NULL GROUP BY mID HAVING COUNT(*) >= 2;
Return the name of the member who is in charge of the most events.? Schema: - member_(Address, Age, COUNT, Card_Number, Country, Hometown, Level, Member_ID, Member_Name, Membership_card, Name, Party_ID, ... (1 more)) - party_events(Event_Name)
SELECT T1.Member_Name FROM member_ AS T1 JOIN party_events AS T2 ON T1.Member_ID = T2.Member_in_charge_ID GROUP BY T2.Member_in_charge_ID, T1.Member_Name ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
What is the number of actors in the movie " Saving Private Ryan " ? 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 T1.name) AS num_actors FROM cast_ AS T2 JOIN actor AS T1 ON T2.aid = T1.aid JOIN movie AS T3 ON T3.mid = T2.msid WHERE T3.title = 'Saving Private Ryan';
Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.? Schema: - course_arrange(...) - course(COUNT, JO, SUM, Stat, T1, course_id, credits, dept_name, title) - teacher(Age, COUNT, D, Hometown, Name)
SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name ASC NULLS LAST;
What is the TV Channel of TV series with Episode "A Love of a Lifetime"? List the TV Channel's series name.? Schema: - TV_Channel(Content, Country, Engl, Hight_definition_TV, Language, Package_Option, Pixel_aspect_ratio_PAR, id, series_name) - TV_series(Air_Date, Episode, Rating, Share, Weekly_Rank)
SELECT T1.series_name FROM TV_Channel AS T1 JOIN TV_series AS T2 ON T1.id = T2.Channel WHERE T2.Episode = 'A Love of a Lifetime';
find the number of players for each country.? Schema: - players(COUNT, birth_date, country_code, first_name, hand, last_name)
SELECT COUNT(*) AS num_players, country_code FROM players GROUP BY country_code;
Find all movies in which " Robin Wright " appears? 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 T2.title 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 = 'Robin Wright';
What are the title and issues of the books? Schema: - book(Ela, Issues, Title, Writer)
SELECT Title, Issues FROM book;
Count the number of climbers.? Schema: - climber(Country, K, Name, Points)
SELECT COUNT(*) AS num_climbers FROM climber;
What are the phone, room, and building of the faculty member called Jerry Prince? Schema: - Faculty(Building, COUNT, FacID, Fname, LName, Lname, Phone, Pr, Rank, Room, Sex)
SELECT Phone, Room, Building FROM Faculty WHERE Fname = 'Jerry' AND Lname = 'Prince';
which river runs through most states? Schema: - river(COUNT, DIST, LENGTH, M, country_name, illino, m, river_name, traverse)
SELECT river_name FROM river GROUP BY (river_name) ORDER BY COUNT(DISTINCT traverse) DESC NULLS LAST LIMIT 1;
conferences for Trophic Cascade? Schema: - paperKeyphrase(...) - keyphrase(...) - paper(For, Switch, journalId, juic, learn, mach, paperId, title, venueId, year)
SELECT DISTINCT T3.venueId FROM paperKeyphrase AS T2 JOIN keyphrase AS T1 ON T2.keyphraseId = T1.keyphraseId JOIN paper AS T3 ON T3.paperId = T2.paperId WHERE T1.keyphraseName = 'Trophic Cascade';
Find the name of the customer who made the order of the largest amount of goods.? 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)
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 WHERE TRY_CAST(T3.order_quantity AS DOUBLE) = (SELECT MAX(TRY_CAST(order_quantity AS DOUBLE)) FROM Order_Items);
How many acting statuses are there? Schema: - management(temporary_acting)
SELECT COUNT(DISTINCT temporary_acting) AS num_statuses FROM management;
How many professors who are from either Accounting or Biology department? Schema: - PROFESSOR(DEPT_CODE, PROF_HIGH_DEGREE) - DEPARTMENT(Account, DEPT_ADDRESS, DEPT_NAME, H, SCHOOL_CODE)
SELECT COUNT(*) AS num_professors FROM PROFESSOR AS T1 JOIN DEPARTMENT AS T2 ON T1.DEPT_CODE = T2.DEPT_CODE WHERE T2.DEPT_NAME = 'Accounting' OR T2.DEPT_NAME = 'Biology';
Which room has the largest number of reservations? Schema: - Reservations(Adults, CheckIn, FirstName, Kids, LastName) - Rooms(K, RoomId, basePrice, bedType, beds, decor, maxOccupancy, roomName)
SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room, T2.roomName ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
How many patients do each physician take care of? List their names and number of patients they take care of.? Schema: - Physician(I, Name) - Patient(...)
SELECT T1.Name, COUNT(*) AS num_patients FROM Physician AS T1 JOIN Patient AS T2 ON T1.EmployeeID = T2.PCP GROUP BY T1.EmployeeID, T1.Name;
How many schools have students playing in goalie and mid-field positions? Schema: - Tryout(COUNT, EX, T1, cName, decision, pPos)
SELECT COUNT(DISTINCT cName) AS num_schools FROM Tryout WHERE pPos = 'goalie' AND cName IN (SELECT cName FROM Tryout WHERE pPos = 'mid');
What are the distinct name of the mills built by the architects who have also built a bridge longer than 80 meters? Schema: - mill(Moul, location, name, type) - architect(gender, id, name, nationality) - bridge(Ra, length_feet, location, name)
SELECT DISTINCT T1.name FROM mill AS T1 JOIN architect AS T2 ON CAST(T1.architect_id AS TEXt) = T2.id JOIN bridge AS T3 ON CAST(T3.architect_id AS TEXT) = T2.id WHERE T3.length_meters > 80;
what are the names and classes of the ships that do not have any captain yet? Schema: - Ship(Built_Year, COUNT, Class, Flag, Name, Type) - captain(COUNT, Class, INT, Name, Rank, TRY_CAST, age, capta, l)
SELECT Name, Class FROM Ship WHERE Ship_ID NOT IN (SELECT Ship_ID FROM captain);
Find the claim that has the largest total settlement amount. Return the effective date of the claim.? Schema: - Claims(Amount_Claimed, Amount_Settled, Date_Claim_Made, Date_Claim_Settled) - Settlements(Amount_Settled, Date_Claim_Made, Date_Claim_Settled, Settlement_Amount)
SELECT T1.Effective_Date FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_ID = T2.Claim_ID GROUP BY T1.Claim_ID, T1.Effective_Date ORDER BY SUM(T2.Settlement_Amount) DESC NULLS LAST LIMIT 1;
return me the number of conferences which have papers by " H. V. Jagadish " .? Schema: - publication(COUNT, Mak, Price, Publ, Publication_Date, Publisher, T1, abstract, citation_num, reference_num, title, year) - conference(homepage, name) - writes(...) - author(...)
SELECT COUNT(DISTINCT T2.name) AS num_conferences FROM publication AS T4 JOIN conference AS T2 ON T4.cid = CAST(T2.cid AS TEXT) JOIN writes AS T3 ON T3.pid = T4.pid JOIN author AS T1 ON T3.aid = T1.aid WHERE T1.name = 'H. V. Jagadish';
Show the faculty id of each faculty member, along with the number of students he or she advises.? Schema: - Faculty(Building, COUNT, FacID, Fname, LName, Lname, Phone, Pr, Rank, Room, Sex) - Student(Advisor, Age, COUNT, Fname, L, LName, M, Major, Sex, StuID, city_code, oldest_age)
SELECT T1.FacID, COUNT(*) AS num_students FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.Advisor GROUP BY T1.FacID;
How many manufacturers have headquarters in either Tokyo or Beijing? Schema: - Manufacturers(Aust, Beij, Founder, Headquarter, I, M, Name, Revenue)
SELECT COUNT(*) AS num_manufacturers FROM Manufacturers WHERE Headquarter = 'Tokyo' OR Headquarter = 'Beijing';
What are the names of all people who do not have friends? Schema: - Person(M, age, city, eng, gender, job, name) - PersonFriend(M, friend, name)
SELECT name FROM Person WHERE name NOT IN (SELECT name FROM PersonFriend);
Find the titles and studios of the films that are produced by some film studios that contained the word "Universal".? Schema: - film(COUNT, Directed_by, Director, Gross_in_dollar, JO, LENGTH, Studio, T1, Title, language_id, rating, rental_rate, ... (3 more))
SELECT Title, Studio FROM film WHERE Studio LIKE '%Universal%';
What is the name of the shop that has the most different kinds of devices in stock? Schema: - stock(Quantity) - shop(Address, District, INT, Location, Manager_name, Name, Number_products, Open_Year, Score, Shop_ID, Shop_Name, T1, ... (1 more))
SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID, T2.Shop_Name ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;
Which teams had more than 3 eliminations? Schema: - Elimination(Benjam, Eliminated_By, Elimination_Move, T1, Team, Time)
SELECT Team FROM Elimination WHERE Team IS NOT NULL GROUP BY Team HAVING COUNT(*) > 3;
Which club has the most female students as their members? Give me the name of the club.? 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.Sex = 'F' GROUP BY T1.ClubName ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1;