database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
school_finance
SELECT count(DISTINCT T1.donator_name) FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = "Glenn"
How many donors have endowment for school named "Glenn"?
school_finance
SELECT donator_name , sum(amount) FROM endowment GROUP BY donator_name ORDER BY sum(amount) DESC
List each donator name and the amount of endowment in descending order of the amount of endowment.
school_finance
SELECT school_name FROM school WHERE school_id NOT IN (SELECT school_id FROM endowment)
List the names of the schools without any endowment.
school_finance
SELECT T2.school_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T1.school_id HAVING sum(T1.amount) <= 10
List all the names of schools with an endowment amount smaller than or equal to 10.
school_finance
SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton'
Show the names of donors who donated to both school "Glenn" and "Triton"
school_finance
SELECT donator_name FROM endowment EXCEPT SELECT donator_name FROM endowment WHERE amount < 9
Show the names of all the donors except those whose donation amount less than 9.
school_finance
SELECT amount , donator_name FROM endowment ORDER BY amount DESC LIMIT 1
List the amount and donor name for the largest amount of donation.
school_finance
SELECT count(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
How many budgets are above 3000 in year 2001 or before?
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
Show each school name, its budgeted amount, and invested amount in year 2002 or after.
school_finance
SELECT sum(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'
What is the total budget amount for school "Glenn" in all years?
school_finance
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING sum(T1.budgeted) > 100 OR sum(T3.amount) > 10
Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.
school_finance
SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING count(*) > 1
Find the names of schools that have more than one donator with donation amount above 8.5.
school_finance
SELECT count(*) FROM (SELECT * FROM endowment WHERE amount < 8.5 GROUP BY school_id HAVING count(*) > 1)
Find the number of schools that have more than one donator whose donation amount is less than 8.5.
film_rank
SELECT max(Number_cities) , min(Number_cities) FROM market
What are the maximum and minimum number of cities in all markets.
film_rank
SELECT DISTINCT T1.Director FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID WHERE T2.Year = 1995
Show the distinct director of films with market estimation in the year of 1995.
film_rank
SELECT avg(T2.Number_cities) FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T1.Low_Estimate > 10000
What is the average number of cities of markets with low film market estimate bigger than 10000?
film_rank
SELECT T1.Year FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T2.Country = "Japan" ORDER BY T1.Year DESC
Please list the years of film market estimations when the market is in country "Japan" in descending order.
film_rank
SELECT Studio FROM film GROUP BY Studio ORDER BY COUNT(*) DESC LIMIT 1
List the name of film studio that have the most number of films.
film_rank
SELECT Studio FROM film GROUP BY Studio HAVING COUNT(*) >= 2
List the names of studios that have at least two films.
film_rank
SELECT Title FROM film WHERE Film_ID NOT IN (SELECT Film_ID FROM film_market_estimation)
List the title of films that do not have any market estimation.
film_rank
SELECT Studio FROM film WHERE Director = "Nicholas Meyer" INTERSECT SELECT Studio FROM film WHERE Director = "Walter Hill"
Show the studios that have produced films with director "Nicholas Meyer" and "Walter Hill".
film_rank
SELECT title , Studio FROM film WHERE Studio LIKE "%Universal%"
Find the titles and studios of the films that are produced by some film studios that contained the word "Universal".
film_rank
SELECT Studio FROM film EXCEPT SELECT Studio FROM film WHERE Director = "Walter Hill"
Show the studios that have not produced films with director "Walter Hill".
film_rank
SELECT Studio FROM film GROUP BY Studio HAVING avg(Gross_in_dollar) >= 4500000
List the studios which average gross is above 4500000.
film_rank
SELECT t1.title FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID ORDER BY high_estimate DESC LIMIT 1
What is the title of the film that has the highest high market estimation.
party_host
SELECT count(*) FROM party
How many parties are there?
party_host
SELECT Party_Theme FROM party ORDER BY Number_of_hosts ASC
List the themes of parties in ascending order of number of hosts.
party_host
SELECT Party_Theme , LOCATION FROM party
What are the themes and locations of parties?
party_host
SELECT First_year , Last_year FROM party WHERE Party_Theme = "Spring" OR Party_Theme = "Teqnology"
Show the first year and last year of parties with theme "Spring" or "Teqnology".
party_host
SELECT avg(Number_of_hosts) FROM party
What is the average number of hosts for parties?
party_host
SELECT LOCATION FROM party ORDER BY Number_of_hosts DESC LIMIT 1
What is the location of the party with the most hosts?
party_host
SELECT Nationality , COUNT(*) FROM HOST GROUP BY Nationality
Show different nationalities along with the number of hosts of each nationality.
party_host
SELECT Nationality FROM HOST GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
Show the most common nationality of hosts.
party_host
SELECT Nationality FROM HOST WHERE Age > 45 INTERSECT SELECT Nationality FROM HOST WHERE Age < 35
Show the nations that have both hosts older than 45 and hosts younger than 35.
party_host
SELECT T3.Party_Theme , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID
Show the themes of parties and the names of the party hosts.
party_host
SELECT T3.Location , T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID ORDER BY T2.Age
Show the locations of parties and the names of the party hosts in ascending order of the age of the host.
party_host
SELECT T3.Location FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T2.Age > 50
Show the locations of parties with hosts older than 50.
party_host
SELECT T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T3.Number_of_hosts > 20
Show the host names for parties with number of hosts greater than 20.
party_host
SELECT Name , Nationality FROM HOST ORDER BY Age DESC LIMIT 1
Show the name and the nationality of the oldest host.
ship_mission
SELECT Name FROM ship WHERE Nationality = "United States" OR Nationality = "United Kingdom"
Show the name of ships whose nationality is either United States or United Kingdom.
ship_mission
SELECT Name FROM ship ORDER BY Tonnage DESC LIMIT 1
What is the name of the ship with the largest tonnage?
ship_mission
SELECT TYPE FROM ship GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1
Please show the most common type of ships.
ship_mission
SELECT Nationality FROM ship GROUP BY Nationality HAVING COUNT(*) > 2
List the nations that have more than two ships.
ship_mission
SELECT T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID WHERE T1.Launched_Year > 1928
Show names of ships involved in a mission launched after 1928.
ship_mission
SELECT DISTINCT T1.Fate FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID WHERE T2.Nationality = "United States"
Show the distinct fate of missions that involve ships with nationality "United States"
ship_mission
SELECT Name FROM ship WHERE Ship_ID NOT IN (SELECT Ship_ID FROM mission)
List the name of ships that are not involved in any mission
company_employee
SELECT Name FROM company WHERE Industry = "Banking" OR Industry = "Retailing"
Show the names of companies in the banking or retailing industry?
company_employee
SELECT max(Market_Value_in_Billion) , min(Market_Value_in_Billion) FROM company
What is the maximum and minimum market value of companies?
company_employee
SELECT Headquarters FROM company ORDER BY Sales_in_Billion DESC LIMIT 1
What is the headquarter of the company with the largest sales?
company_employee
SELECT Headquarters FROM company GROUP BY Headquarters ORDER BY COUNT(*) DESC LIMIT 1
Show the most common headquarter for companies.
company_employee
SELECT Headquarters FROM company GROUP BY Headquarters HAVING COUNT(*) >= 2
Show the headquarters that have at least two companies.
company_employee
SELECT Headquarters FROM company WHERE Industry = "Banking" INTERSECT SELECT Headquarters FROM company WHERE Industry = "Oil and gas"
Show the headquarters that have both companies in banking industry and companies in oil and gas industry.
company_employee
SELECT T3.Name , T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID
Show the names of companies and of employees.
company_employee
SELECT T3.Name , T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID ORDER BY T1.Year_working
Show names of companies and that of employees in descending order of number of years working for that employee.
company_employee
SELECT T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID WHERE T3.Sales_in_Billion > 200
Show the names of employees that work for companies with sales bigger than 200.
company_employee
SELECT T3.Name , COUNT(*) FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID GROUP BY T3.Name
Show the names of companies and the number of employees they have
company_employee
SELECT Name FROM people WHERE People_ID NOT IN (SELECT People_ID FROM employment)
List the names of people that are not employed by any company
tracking_share_transactions
SELECT min(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50
Show the minimum amount of transactions whose type code is "PUR" and whose share count is bigger than 50.
tracking_share_transactions
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000
Show the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000.
tracking_share_transactions
SELECT T1.transaction_type_description , T2.date_of_transaction FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code WHERE T2.share_count < 10
Show the transaction type descriptions and dates if the share count is smaller than 10.
tracking_share_transactions
SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100
Show details of all investors if they make any transaction with share count greater than 100.
tracking_share_transactions
SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l"
Return the lot details of lots that belong to investors with details "l"?
tracking_share_transactions
SELECT T1.purchase_details FROM PURCHASES AS T1 JOIN TRANSACTIONS AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000
What are the purchase details of transactions with amount bigger than 10000?
tracking_share_transactions
SELECT T1.sales_details , T2.date_of_transaction FROM SALES AS T1 JOIN TRANSACTIONS AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000
What are the sale details and dates of transactions with amount smaller than 3000?
tracking_share_transactions
SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count < 50
What are the lot details of lots associated with transactions with share count smaller than 50?
tracking_share_transactions
SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count > 100 AND T3.transaction_type_code = "PUR"
What are the lot details of lots associated with transactions whose share count is bigger than 100 and whose type code is "PUR"?
tracking_share_transactions
SELECT transaction_type_code , max(share_count) , min(share_count) FROM TRANSACTIONS GROUP BY transaction_type_code
Show the maximum and minimum share count of different transaction types.
tracking_share_transactions
SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY avg(share_count)
Show the average share count of transactions made by each investor, ordered by average share count.
tracking_share_transactions
SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id
Show the average amount of transactions for different lots.
tracking_share_transactions
SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id ORDER BY avg(amount_of_transaction)
Show the average amount of transactions for different lots, ordered by average amount of transactions.
tracking_share_transactions
SELECT investor_id , COUNT(*) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" GROUP BY investor_id
Show the number of transactions with transaction type code "SALE" for different investors if it is larger than 0.
tracking_share_transactions
SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) ASC LIMIT 1
Show the transaction type code that occurs the fewest times.
tracking_share_transactions
SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
Show the transaction type code that occurs the most frequently.
tracking_share_transactions
SELECT T1.transaction_type_description FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code GROUP BY T1.transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
Show the description of the transaction type that occurs most frequently.
tracking_share_transactions
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 1
Show the id and details of the investor that has the largest number of transactions.
tracking_share_transactions
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 3
Show the id and details for the investors who have the top 3 number of transactions.
tracking_share_transactions
SELECT T2.investor_id FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id HAVING COUNT(*) >= 2
Show the ids of the investors who have at least two transactions.
tracking_share_transactions
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" GROUP BY T2.investor_id HAVING COUNT(*) >= 2
Show the ids and details of the investors who have at least two transactions with type code "SALE".
tracking_share_transactions
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100
What are the dates of transactions with at least 100 share count or amount bigger than 100?
tracking_share_transactions
SELECT sales_details FROM sales UNION SELECT purchase_details FROM purchases
What are the details of all sales and purchases?
news_report
SELECT Name FROM journalist WHERE Nationality = "England" OR Nationality = "Wales"
Show the names of journalists FROM "England" or "Wales".
news_report
SELECT Nationality FROM journalist ORDER BY Years_working DESC LIMIT 1
What is the nationality of the journalist with the largest number of years working?
news_report
SELECT Nationality FROM journalist GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
Show the most common nationality for journalists.
news_report
SELECT Nationality FROM journalist WHERE Years_working > 10 INTERSECT SELECT Nationality FROM journalist WHERE Years_working < 3
Show the nations that have both journalists with more than 10 years of working and journalists with less than 3 years of working.
news_report
SELECT T3.Name , T2.Date FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID
Show the names of journalists and the dates of the events they reported.
news_report
SELECT T3.Name , T2.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID ORDER BY T2.Event_Attendance ASC
Show the names of journalists and the names of the events they reported in ascending order
news_report
SELECT T3.Name , COUNT(*) FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name
Show the names of journalists and the number of events they reported.
news_report
SELECT T3.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name HAVING COUNT(*) > 1
Show the names of journalists that have reported more than one event.
news_report
SELECT Name FROM journalist WHERE journalist_ID NOT IN (SELECT journalist_ID FROM news_report)
List the names of journalists who have not reported any event.
news_report
SELECT avg(Event_Attendance) , max(Event_Attendance) FROM event
what are the average and maximum attendances of all events?
news_report
SELECT avg(t1.age) , avg(Years_working) , t2.work_type FROM journalist AS t1 JOIN news_report AS t2 ON t1.journalist_id = t2.journalist_id GROUP BY t2.work_type
Find the average age and experience working length of journalists working on different role type.
storm_record
SELECT region_code , region_name FROM region ORDER BY region_code;
Show all region code and region name sorted by the codes.
storm_record
SELECT region_name FROM region ORDER BY region_name;
List all region names in alphabetical order.
storm_record
SELECT region_name FROM region WHERE region_name != 'Denmark';
Show names for all regions except for Denmark.
storm_record
SELECT count(*) FROM storm WHERE Number_Deaths > 0;
How many storms had death records?
storm_record
SELECT name , dates_active , number_deaths FROM storm WHERE number_deaths >= 1;
List name, dates active, and number of deaths for all storms with at least 1 death.
storm_record
SELECT avg(damage_millions_USD) , max(damage_millions_USD) FROM storm WHERE max_speed > 1000;
Show the average and maximum damage for all storms with max speed higher than 1000.
storm_record
SELECT sum(number_deaths) , sum(damage_millions_USD) FROM storm WHERE max_speed > (SELECT avg(max_speed) FROM storm);
What is the total number of deaths and damage for all storms with a max speed greater than the average?
storm_record
SELECT name , damage_millions_USD FROM storm ORDER BY max_speed DESC;
List name and damage for all storms in a descending order of max speed.
storm_record
SELECT count(DISTINCT region_id) FROM affected_region
How many regions are affected?