database_id stringlengths 4 31 | query stringlengths 22 577 | question stringlengths 19 224 |
|---|---|---|
small_bank_1 | SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%' | What is the checking balance of the account whose owner’s name contains the substring ‘ee’? |
small_bank_1 | SELECT T2.balance, T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T1.name = 'Brown' | Find the checking balance and saving balance in the Brown’s account. |
small_bank_1 | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT avg(balance) FROM savings) | Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance. |
small_bank_1 | SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT avg(balance) FROM savings)) | Find the checking balance of the accounts whose savings balance is higher than the average savings balance. |
small_bank_1 | SELECT T1.name 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 + T3.balance LIMIT 1 | Find the name of account that has the lowest total checking and saving balance. |
small_bank_1 | SELECT T1.name, T2.balance + T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance > (SELECT avg(balance) FROM savings) | Find the names and total checking and savings balances of accounts whose savings balance is higher than the average savings balance. |
small_bank_1 | SELECT T1.name, T2.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 T3.balance LIMIT 1 | Find the name and checking balance of the account with the lowest savings balance. |
small_bank_1 | SELECT count(*), T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid GROUP BY T1.name | Find the number of checking accounts for each account name. |
small_bank_1 | SELECT sum(T2.balance) , T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid GROUP BY T1.name | Find the total saving balance for each account name. |
small_bank_1 | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT avg(balance) FROM checking) | Find the name of accounts whose checking balance is below the average checking balance. |
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 | Find the saving balance of the account with the highest checking balance. |
small_bank_1 | SELECT T1.balance + T2.balance FROM checking AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T1.balance + T2.balance | Find the total checking and saving balance of all accounts sorted by the total balance in ascending order. |
small_bank_1 | SELECT T2.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T3.balance LIMIT 1 | Find the name and checking balance of the account with the lowest saving balance. |
small_bank_1 | SELECT T2.balance , T3.balance , T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid | Find the name, checking balance and saving balance of all accounts in the bank. |
small_bank_1 | SELECT T2.balance , T3.balance , T1.name 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 + T3.balance DESC | Find the name, checking balance and savings balance of all accounts in the bank sorted by their total checking and savings balance in descending order. |
small_bank_1 | SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T2.balance > T3.balance | Find the name of accounts whose checking balance is higher than corresponding saving balance. |
small_bank_1 | SELECT T1.name, T3.balance + T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance < T2.balance | Find the name and total checking and savings balance of the accounts whose savings balance is lower than corresponding checking balance. |
chinook_1 | SELECT Name FROM ARTIST WHERE Name LIKE "%a%" | Find the names of all artists that have "a" in their names. |
chinook_1 | SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "AC/DC" | Find the title of all the albums of the artist "AC/DC". |
chinook_1 | SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "Metallica" | How many albums does the artist "Metallica" have? |
chinook_1 | SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = "Balls to the Wall" | Which artist does the album "Balls to the Wall" belong to? |
chinook_1 | SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId GROUP BY T2.Name ORDER BY COUNT(*) DESC LIMIT 1 | Which artist has the most albums? |
chinook_1 | SELECT Name FROM TRACK WHERE Name LIKE '%you%' | Find the names of all the tracks that contain the word "you". |
chinook_1 | SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK | What are the durations of the longest and the shortest tracks in milliseconds? |
chinook_1 | SELECT T1.Title , T2.AlbumID , COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID | Show the album names, ids and the number of tracks for each album. |
chinook_1 | SELECT T1.Name FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId GROUP BY T2.GenreId ORDER BY COUNT(*) DESC LIMIT 1 | What is the name of the most common genre in all tracks? |
chinook_1 | SELECT T1.Name FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.MediaTypeId ORDER BY COUNT(*) ASC LIMIT 1 | What is the least common media type in all tracks? |
chinook_1 | SELECT T1.Title , T2.AlbumID FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId WHERE T2.UnitPrice > 1 GROUP BY T2.AlbumID | Show the album names and ids for albums that contain tracks with unit price bigger than 1. |
chinook_1 | SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | How many tracks belong to rock genre? |
chinook_1 | SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Jazz" | What is the average unit price of tracks that belong to Jazz genre? |
chinook_1 | SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%" | How many customers have email that contains "gmail.com"? |
chinook_1 | SELECT T2.FirstName , T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = "Leonie" | What is the first name and last name employee helps the customer with first name Leonie? |
chinook_1 | SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = "70174" | What city does the employee who helps the customer with postal code 70174 live in? |
chinook_1 | SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = "Astrid" AND LastName = "Gruber" | Find all invoice dates corresponding to customers with first name Astrid and last name Gruber. |
chinook_1 | SELECT LastName FROM CUSTOMER EXCEPT SELECT T1.LastName FROM CUSTOMER AS T1 JOIN Invoice AS T2 ON T1.CustomerId = T2.CustomerId WHERE T2.total > 20 | Find all the customer last names that do not have invoice totals larger than 20. |
chinook_1 | SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Brazil" | Find the first names of all customers that live in Brazil and have an invoice. |
chinook_1 | SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Germany" | Find the address of all customers that live in Germany and have invoice. |
chinook_1 | SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = "AAC audio file" | How many tracks are in the AAC audio file media type? |
chinook_1 | SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Latin" OR T1.Name = "Pop" | What is the average duration in milliseconds of tracks that belong to Latin or Pop genre? |
chinook_1 | SELECT T1.FirstName , T1.SupportRepId FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) >= 10 | Please show the employee first names and ids of employees who serve at least 10 customers. |
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 | Please show the employee last names that serves no more than 20 customers. |
chinook_1 | SELECT T2.Name , T1.ArtistId FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistID GROUP BY T1.ArtistId HAVING COUNT(*) >= 3 ORDER BY T2.Name | Please list the name and id of all artists that have at least 3 albums in alphabetical order. |
chinook_1 | SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId | Find the names of artists that do not have any albums. |
chinook_1 | SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | What is the average unit price of rock tracks? |
chinook_1 | SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Pop" | What are the duration of the longest and shortest pop tracks in milliseconds? |
chinook_1 | SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM) | How many artists do not have any album? |
entrepreneur | SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor != "Rachel Elnaugh" | What are the names of entrepreneurs whose investor is not "Rachel Elnaugh"? |
entrepreneur | SELECT Weight FROM people ORDER BY Height ASC LIMIT 1 | What is the weight of the shortest person? |
entrepreneur | SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Weight DESC LIMIT 1 | What is the name of the entrepreneur with the greatest weight? |
entrepreneur | SELECT sum(T1.Money_Requested) FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Height > 1.85 | What is the total money requested by entrepreneurs with height more than 1.85? |
entrepreneur | SELECT T2.Date_of_Birth FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor = "Simon Woodroffe" OR T1.Investor = "Peter Jones" | What are the dates of birth of entrepreneurs with investor "Simon Woodroffe" or "Peter Jones"? |
entrepreneur | SELECT T2.Weight FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Money_Requested DESC | What are the weights of entrepreneurs in descending order of money requested? |
entrepreneur | SELECT Investor FROM entrepreneur GROUP BY Investor ORDER BY COUNT(*) DESC LIMIT 1 | Who is the investor that has invested in the most number of entrepreneurs? |
entrepreneur | SELECT Investor FROM entrepreneur GROUP BY Investor HAVING COUNT(*) >= 2 | Who are the investors that have invested in at least two entrepreneurs? |
entrepreneur | SELECT T2.Name , T1.Company FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Money_Requested | List the names of entrepreneurs and their companies in descending order of money requested? |
entrepreneur | SELECT Name FROM people WHERE People_ID NOT IN (SELECT People_ID FROM entrepreneur) | List the names of people that are not entrepreneurs. |
entrepreneur | SELECT Investor FROM entrepreneur WHERE Money_Requested > 140000 INTERSECT SELECT Investor FROM entrepreneur WHERE Money_Requested < 120000 | Show the investors shared by entrepreneurs that requested more than 140000 and entrepreneurs that requested less than 120000. |
farm | SELECT max(Cows) , min(Cows) FROM farm | What are the maximum and minimum number of cows across all farms. |
farm | SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1 | List the official name and status of the city with the largest population. |
farm | SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1 | Show the official names of the cities that have hosted more than one competition. |
farm | SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1 | Show the status of the city that has hosted the greatest number of competitions. |
farm | SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000 | Please show the themes of competitions with host cities having populations larger than 1000. |
farm | SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC | Please show the different statuses, ordered by the number of cities that have each. |
farm | SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1 | List the most common type of Status across cities. |
farm | SELECT Official_Name FROM city WHERE City_ID NOT IN (SELECT Host_city_ID FROM farm_competition) | List the official names of cities that have not held any competition. |
farm | SELECT Status FROM city WHERE Population > 1500 INTERSECT SELECT Status FROM city WHERE Population < 500 | Show the status shared by cities with population bigger than 1500 and smaller than 500. |
gymnast | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T2.Hometown != "Santo Domingo" | What are the names of gymnasts whose hometown is not "Santo Domingo"? |
gymnast | SELECT Age FROM people ORDER BY Height DESC LIMIT 1 | What is the age of the tallest person? |
gymnast | SELECT Name FROM People ORDER BY Age DESC LIMIT 5 | List the names of the top 5 oldest people. |
gymnast | SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Age ASC LIMIT 1 | What is the total point count of the youngest gymnast? |
gymnast | SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T1.Total_Points > 57.5 | What are the distinct hometowns of gymnasts with total points more than 57.5? |
gymnast | SELECT T2.Hometown , COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown | What are the hometowns of gymnasts and the corresponding number of gymnasts? |
gymnast | SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown ORDER BY COUNT(*) DESC LIMIT 1 | What is the most common hometown of gymnasts? |
gymnast | SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown HAVING COUNT(*) >= 2 | What are the hometowns that are shared by at least two gymnasts? |
gymnast | SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Height ASC | List the names of gymnasts in ascending order by their heights. |
gymnast | SELECT DISTINCT Hometown FROM people EXCEPT SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID | List the distinct hometowns that are not associated with any gymnast. |
gymnast | SELECT Hometown FROM people WHERE Age > 23 INTERSECT SELECT Hometown FROM people WHERE Age < 20 | Show the hometowns shared by people older than 23 and younger than 20. |
phone_market | SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile" | Show the names of phones with carrier either "Sprint" or "TMobile". |
phone_market | SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1 | What is the carrier of the most expensive phone? |
phone_market | SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1 | Show the most frequently used carrier of the phones. |
phone_market | SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64 | Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64. |
phone_market | SELECT T3.Name , T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID | Show the names of phones and the districts of markets they are on. |
phone_market | SELECT T3.Name , T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking | Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market. |
phone_market | SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50 | Show the names of phones that are on market with number of shops greater than 50. |
phone_market | SELECT T2.Name , sum(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name | For each phone, show its names and total number of stocks. |
phone_market | SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING sum(T1.Num_of_stock) >= 2000 ORDER BY sum(T1.Num_of_stock) DESC | Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks. |
election_representative | SELECT min(Vote_Percent) , max(Vote_Percent) FROM election | What are the minimum and maximum vote percents of elections? |
election_representative | SELECT Lifespan FROM representative WHERE State = "New York" OR State = "Indiana" | What are the life spans of representatives from New York state or Indiana state? |
election_representative | SELECT T2.Name FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID WHERE Votes > 10000 | What are the names of representatives with more than 10000 votes in election? |
election_representative | SELECT T2.Name FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID ORDER BY votes DESC | What are the names of representatives in descending order of votes? |
election_representative | SELECT T2.Party FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID ORDER BY votes ASC LIMIT 1 | What is the party of the representative that has the smallest number of votes. |
election_representative | SELECT T2.Lifespan FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID ORDER BY Vote_Percent DESC | What are the lifespans of representatives in descending order of vote percent? |
election_representative | SELECT avg(T1.Votes) FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID WHERE T2.Party = "Republican" | What is the average number of votes of representatives from party "Republican"? |
election_representative | SELECT Party , COUNT(*) FROM representative GROUP BY Party ORDER BY COUNT(*) DESC LIMIT 1 | What is the party that has the largest number of representatives? |
election_representative | SELECT Party FROM representative GROUP BY Party HAVING COUNT(*) >= 3 | What parties have at least three representatives? |
election_representative | SELECT State FROM representative GROUP BY State HAVING COUNT(*) >= 2 | What states have at least two representatives? |
election_representative | SELECT Name FROM representative WHERE Representative_ID NOT IN (SELECT Representative_ID FROM election) | List the names of representatives that have not participated in elections listed here. |
formula_1 | SELECT name FROM races ORDER BY date DESC LIMIT 1 | What is the name of the race held most recently? |
formula_1 | SELECT name , date FROM races ORDER BY date DESC LIMIT 1 | What is the name and date of the most recent race? |
formula_1 | SELECT name FROM races WHERE YEAR = 2017 | Find the names of all races held in 2017. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.