question
stringlengths 63
269
| answer
stringlengths 18
557
|
---|---|
Find the 'date became customers' of the customers whose ID is between 10 and 20.
Additional table information: table: customers_and_addresses | SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20 |
Find the code of the role that have the most employees.
Additional table information: table: cre_Doc_Tracking_DB | SELECT role_code FROM Employees GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1 |
What are the main indstries and total market value for each industry?
Additional table information: table: gas_company | SELECT main_industry, SUM(market_value) FROM company GROUP BY main_industry |
List the first name of all employees with job code PROF ordered by their date of birth.
Additional table information: table: college_1 | SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob NULLS FIRST |
How many students are in each department?
Additional table information: table: college_2 | SELECT COUNT(*), dept_name FROM student GROUP BY dept_name |
what is the name of the instructor who is in Statistics department and earns the lowest salary?
Additional table information: table: college_2 | SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary NULLS FIRST LIMIT 1 |
What is the first and last name of the faculty participating in the most activities?
Additional table information: table: activity_1 | SELECT T1.fname, T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID GROUP BY T1.FacID ORDER BY COUNT(*) DESC LIMIT 1 |
Find the number of papers published by authors from the institution 'Tokohu University'.
Additional table information: table: icfp_1 | SELECT COUNT(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Tokohu University' |
Find the saving balance of the account with the highest checking balance.
Additional table information: table: small_bank_1 | SELECT T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T2.balance DESC LIMIT 1 |
What is the title of the course that was offered at building Chandler during the fall semester in the year of 2010?
Additional table information: table: college_2 | SELECT T1.title FROM course AS T1 JOIN SECTION AS T2 ON T1.course_id = T2.course_id WHERE building = 'Chandler' AND semester = 'Fall' AND YEAR = 2010 |
How many different instruments are used in the song 'Le Pop'?
Additional table information: table: music_2 | SELECT COUNT(DISTINCT instrument) FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = 'Le Pop' |
What are the names of projects that require between 100 and 300 hours?
Additional table information: table: scientist_1 | SELECT name FROM projects WHERE hours BETWEEN 100 AND 300 |
Show all card type codes and the number of customers holding cards in each type.
Additional table information: table: customers_card_transactions | SELECT card_type_code, COUNT(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code |
Which months have more than 2 happy hours?
Additional table information: table: coffee_shop | SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING COUNT(*) > 2 |
Show the outcome code of mailshots along with the number of mailshots in each outcome code.
Additional table information: table: customers_campaigns_ecommerce | SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code |
What is the average rating of songs for each language?
Additional table information: table: music_1 | SELECT AVG(rating), languages FROM song GROUP BY languages |
Show student ids who don't have any sports.
Additional table information: table: game_1 | SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo |
Take the average of the school enrollment.
Additional table information: table: school_player | SELECT AVG(Enrollment) FROM school |
What are the names of musicals who have at 3 or more actors?
Additional table information: table: musical | SELECT T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID HAVING COUNT(*) >= 3 |
How many players have more than 1000 hours of training?
Additional table information: table: soccer_2 | SELECT COUNT(*) FROM Player WHERE HS > 1000 |
What are the names and ids of stations that had more than 14 bikes available on average or were installed in December?
Additional table information: table: bike_1 | SELECT T1.name, T1.id FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING AVG(T2.bikes_available) > 14 UNION SELECT name, id FROM station WHERE installation_date LIKE '12/%' |
What are the name and description for role code 'MG'?
Additional table information: table: cre_Doc_Tracking_DB | SELECT role_name, role_description FROM ROLES WHERE role_code = 'MG' |
Show details of all visitors.
Additional table information: table: cre_Theme_park | SELECT Tourist_Details FROM VISITORS |
How many lessons did the customer Ryan Goodwin complete?
Additional table information: table: driving_school | SELECT COUNT(*) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Rylan' AND T2.last_name = 'Goodwin' AND T1.lesson_status_code = 'Completed' |
Find the name of the ships that are steered by both a captain with Midshipman rank and a captain with Lieutenant rank.
Additional table information: table: ship_1 | SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Midshipman' INTERSECT SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Lieutenant' |
Show gas station id, location, and manager_name for all gas stations ordered by open year.
Additional table information: table: gas_company | SELECT station_id, LOCATION, manager_name FROM gas_station ORDER BY open_year NULLS FIRST |
How many roller coasters are there?
Additional table information: table: roller_coaster | SELECT COUNT(*) FROM roller_coaster |
Find the first name and last name and department id for those employees who earn such amount of salary which is the smallest salary of any of the departments.
Additional table information: table: hr_1 | SELECT first_name, last_name, department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id) |
What is the average and largest salary of all employees?
Additional table information: table: flight_1 | SELECT AVG(salary), MAX(salary) FROM Employee |
What are all the policy types of the customer that has the most policies listed?
Additional table information: table: insurance_fnol | SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY COUNT(*) DESC LIMIT 1) |
What is the average sales of the journals that have an editor whose work type is 'Photo'?
Additional table information: table: journal_committee | SELECT AVG(T1.sales) FROM journal AS T1 JOIN journal_committee AS T2 ON T1.journal_ID = T2.journal_ID WHERE T2.work_type = 'Photo' |
Find the names of customers who have used both the service 'Close a policy' and the service 'New policy application'.
Additional table information: table: insurance_fnol | SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = 'Close a policy' INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = 'New policy application' |
list the local authorities and services provided by all stations.
Additional table information: table: station_weather | SELECT local_authority, services FROM station |
Find the payment method that is used most frequently.
Additional table information: table: customers_and_addresses | SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1 |
What are full names and salaries of employees working in the city of London?
Additional table information: table: hr_1 | SELECT first_name, last_name, salary 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 WHERE T3.city = 'London' |
What is the maximum and minimum market value of companies?
Additional table information: table: company_employee | SELECT MAX(Market_Value_in_Billion), MIN(Market_Value_in_Billion) FROM company |
Find all the ids and dates of the logs for the problem whose id is 10.
Additional table information: table: tracking_software_problems | SELECT problem_log_id, log_entry_date FROM problem_log WHERE problem_id = 10 |
What are the themes of farm competitions sorted by year in ascending order?
Additional table information: table: farm | SELECT Theme FROM farm_competition ORDER BY YEAR ASC NULLS FIRST |
What are the names of teams from universities that have a below average enrollment?
Additional table information: table: university_basketball | SELECT t2.team_name FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id WHERE enrollment < (SELECT AVG(enrollment) FROM university) |
Which rank has the smallest number of faculty members?
Additional table information: table: activity_1 | SELECT rank FROM Faculty GROUP BY rank ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1 |
What is the name of the county with the greatest population?
Additional table information: table: county_public_safety | SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1 |
What are the distinct location names?
Additional table information: table: cre_Theme_park | SELECT DISTINCT Location_Name FROM LOCATIONS |
For each city, how many branches opened before 2010?
Additional table information: table: shop_membership | SELECT city, COUNT(*) FROM branch WHERE open_year < 2010 GROUP BY city |
What are the names of ships that have more than one captain?
Additional table information: table: ship_1 | SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id GROUP BY t2.ship_id HAVING COUNT(*) > 1 |
Find the type code of the most frequently used policy.
Additional table information: table: insurance_and_eClaims | SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1 |
What is the membership level with the most people?
Additional table information: table: shop_membership | SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY COUNT(*) DESC LIMIT 1 |
What are the different types of forms?
Additional table information: table: e_government | SELECT DISTINCT form_type_code FROM forms |
Find the number of tweets in record.
Additional table information: table: twitter_1 | SELECT COUNT(*) FROM tweets |
What are the renting arrears tax ids related to the customer master index whose detail is not 'Schmidt, Kertzmann and Lubowitz'?
Additional table information: table: local_govt_mdm | SELECT T1.council_tax_id FROM Rent_Arrears AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id JOIN Customer_Master_Index AS T3 ON T3.master_customer_id = T2.master_customer_id WHERE T3.cmi_details <> 'Schmidt , Kertzmann and Lubowitz' |
Show each school name, its budgeted amount, and invested amount in year 2002 or after.
Additional table information: table: school_finance | SELECT T2.school_name, T1.budgeted, T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002 |
Please show the employee last names that serves no more than 20 customers.
Additional table information: table: chinook_1 | SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20 |
Show the season, the player, and the name of the team that players belong to.
Additional table information: table: match_season | SELECT T1.Season, T1.Player, T2.Name FROM match_season AS T1 JOIN team AS T2 ON T1.Team = T2.Team_id |
How many customers live in Prague city?
Additional table information: table: store_1 | SELECT COUNT(*) FROM customers WHERE city = 'Prague' |
What is the height of the mountain climbined by the climbing who had the most points?
Additional table information: table: climbing | SELECT T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID = T2.Mountain_ID ORDER BY T1.Points DESC LIMIT 1 |
Find the name of companies that do not make DVD drive.
Additional table information: table: manufactory_1 | SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.manufacturer = T2.code WHERE T1.name = 'DVD drive' |
What are the names of countries that have both players with position forward and players with position defender?
Additional table information: table: match_season | SELECT T1.Country_name FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.Position = 'Forward' INTERSECT SELECT T1.Country_name FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.Position = 'Defender' |
What is the total number of points for all players?
Additional table information: table: sports_competition | SELECT SUM(Points) FROM player |
Find the names and number of works of the three artists who have produced the most songs.
Additional table information: table: music_1 | SELECT T1.artist_name, COUNT(*) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name GROUP BY T2.artist_name ORDER BY COUNT(*) DESC LIMIT 3 |
For each company, return the company name and the name of the building its office is located in.
Additional table information: table: company_office | SELECT T3.name, T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id |
What is the name of the customer with the worst credit score?
Additional table information: table: loan_1 | SELECT cust_name FROM customer ORDER BY credit_score NULLS FIRST LIMIT 1 |
How many addresses have zip code 197?
Additional table information: table: behavior_monitoring | SELECT COUNT(*) FROM ADDRESSES WHERE zip_postcode = '197' |
List the order dates of all the bookings.
Additional table information: table: cre_Drama_Workshop_Groups | SELECT Order_Date FROM BOOKINGS |
How many distinct hometowns did these people have?
Additional table information: table: gymnast | SELECT COUNT(DISTINCT Hometown) FROM people |
What are the names of all females who are friends with Zach?
Additional table information: table: network_2 | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female' |
For each delegate, find the names of the party they are part of.
Additional table information: table: election | SELECT T1.Delegate, T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID |
Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.
Additional table information: table: cinema | SELECT AVG(capacity), MIN(capacity), MAX(capacity) FROM cinema WHERE openning_year >= 2011 |
What is the id of every employee who has at least a salary of 100000?
Additional table information: table: flight_1 | SELECT eid FROM Employee WHERE salary > 100000 |
Count the number of distinct delegates who are from counties with population above 50000.
Additional table information: table: election | SELECT COUNT(DISTINCT T2.Delegate) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population > 50000 |
How many churches have a wedding in year 2016?
Additional table information: table: wedding | SELECT COUNT(DISTINCT church_id) FROM wedding WHERE YEAR = 2016 |
Which countries has the most number of airlines?
Additional table information: table: flight_4 | SELECT country FROM airlines GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1 |
Count the number of accounts.
Additional table information: table: small_bank_1 | SELECT COUNT(*) FROM accounts |
Give me the payment Id, the date and the amount for all the payments processed with Visa.
Additional table information: table: insurance_policies | SELECT Payment_ID, Date_Payment_Made, Amount_Payment FROM Payments WHERE Payment_Method_Code = 'Visa' |
What is the average credit score for customers who have taken a loan?
Additional table information: table: loan_1 | SELECT AVG(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan) |
What is the address content of the customer named 'Maudie Kertzmann'?
Additional table information: table: customers_and_addresses | SELECT t3.address_content FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t1.customer_name = 'Maudie Kertzmann' |
What are the names of musicals who have no actors?
Additional table information: table: musical | SELECT Name FROM musical WHERE NOT Musical_ID IN (SELECT Musical_ID FROM actor) |
How many professors teach a class with the code ACCT-211?
Additional table information: table: college_1 | SELECT COUNT(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = 'ACCT-211' |
How many females are in the network?
Additional table information: table: network_2 | SELECT COUNT(*) FROM Person WHERE gender = 'female' |
What is the name of each camera lens and the number of photos taken by it? Order the result by the count of photos.
Additional table information: table: mountain_photos | SELECT T1.name, COUNT(*) FROM camera_lens AS T1 JOIN photos AS T2 ON T1.id = T2.camera_lens_id GROUP BY T1.id ORDER BY COUNT(*) NULLS FIRST |
What is the starting year of the oldest technicians?
Additional table information: table: machine_repair | SELECT Starting_Year FROM technician ORDER BY Age DESC LIMIT 1 |
What is the code of the school where the accounting department belongs to?
Additional table information: table: college_1 | SELECT school_code FROM department WHERE dept_name = 'Accounting' |
How many distinct characteristic names does the product 'cumin' have?
Additional table information: table: products_gen_characteristics | SELECT COUNT(DISTINCT t3.characteristic_name) 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 WHERE t1.product_name = 'sesame' |
What is the number of distinct teams that suffer elimination?
Additional table information: table: wrestler | SELECT COUNT(DISTINCT team) FROM elimination |
What are the codes of the locations with at least three documents?
Additional table information: table: cre_Doc_Tracking_DB | SELECT location_code FROM Document_locations GROUP BY location_code HAVING COUNT(*) >= 3 |
Which building has most faculty members?
Additional table information: table: activity_1 | SELECT building FROM Faculty GROUP BY building ORDER BY COUNT(*) DESC LIMIT 1 |
Find the first names of professors who are teaching more than one class.
Additional table information: table: college_1 | SELECT T2.emp_fname FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num GROUP BY T1.prof_num HAVING COUNT(*) > 1 |
Show party names and the number of events for each party.
Additional table information: table: party_people | SELECT T2.party_name, COUNT(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id |
Count the number of different account types.
Additional table information: table: loan_1 | SELECT COUNT(DISTINCT acc_type) FROM customer |
How many days had both mean humidity above 50 and mean visibility above 8?
Additional table information: table: bike_1 | SELECT COUNT(*) FROM weather WHERE mean_humidity > 50 AND mean_visibility_miles > 8 |
What are the type codes and descriptions of each budget type?
Additional table information: table: cre_Docs_and_Epenses | SELECT budget_type_code, budget_type_description FROM Ref_budget_codes |
What is the name of the youngest male?
Additional table information: table: network_2 | SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT MIN(age) FROM person WHERE gender = 'male') |
Find the minimum salary for the departments whose average salary is above the average payment of all instructors.
Additional table information: table: college_2 | SELECT MIN(salary), dept_name FROM instructor GROUP BY dept_name HAVING AVG(salary) > (SELECT AVG(salary) FROM instructor) |
Return the hosts of competitions for which the theme is not Aliens?
Additional table information: table: farm | SELECT Hosts FROM farm_competition WHERE Theme <> 'Aliens' |
What is the location of the perpetrator with the largest kills.
Additional table information: table: perpetrator | SELECT LOCATION FROM perpetrator ORDER BY Killed DESC LIMIT 1 |
when is the hire date for those employees whose first name does not containing the letter M?
Additional table information: table: hr_1 | SELECT hire_date FROM employees WHERE NOT first_name LIKE '%M%' |
Find all the players' first name and last name who have empty death record.
Additional table information: table: baseball_1 | SELECT name_first, name_last FROM player WHERE death_year = '' |
What is the average number of working horses of farms with more than 5000 total number of horses?
Additional table information: table: farm | SELECT AVG(Working_Horses) FROM farm WHERE Total_Horses > 5000 |
Show the names of members and the dates of performances they attended in descending order of attendance of the performances.
Additional table information: table: performance_attendance | SELECT T2.Name, T3.Date FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID ORDER BY T3.Attendance DESC |
What are the maximum price and score of wines for each year?
Additional table information: table: wine_1 | SELECT MAX(Price), MAX(Score), YEAR FROM WINE GROUP BY YEAR |
Show the number of card types.
Additional table information: table: customers_card_transactions | SELECT COUNT(DISTINCT card_type_code) FROM Customers_Cards |
How many airports' names have the word Interanation in them?
Additional table information: table: flight_4 | SELECT COUNT(*) FROM airports WHERE name LIKE '%International%' |