input
stringlengths
236
16.9k
output
stringlengths
19
805
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the dates that have an average sea level pressure between 30.3 and 31?
SELECT date FROM weather WHERE mean_sea_level_pressure_inches BETWEEN 30.3 AND 31;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- Find the day in which the difference between the max temperature and min temperature was the smallest. Also report the difference.
SELECT date , max_temperature_f - min_temperature_f FROM weather ORDER BY max_temperature_f - min_temperature_f LIMIT 1;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the days that had the smallest temperature range, and what was that range?
SELECT date , max_temperature_f - min_temperature_f FROM weather ORDER BY max_temperature_f - min_temperature_f LIMIT 1;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the id and name of the stations that have ever had more than 12 bikes available?
SELECT DISTINCT T1.id , T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available > 12;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the different ids and names of the stations that have had more than 12 bikes available?
SELECT DISTINCT T1.id , T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available > 12;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- Give me the zip code where the average mean humidity is below 70 and at least 100 trips took place.
SELECT zip_code FROM weather GROUP BY zip_code HAVING avg(mean_humidity) < 70 INTERSECT SELECT zip_code FROM trip GROUP BY zip_code HAVING count(*) >= 100;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the zip codes that have an average mean humidity below 70 and had at least 100 trips come through there?
SELECT zip_code FROM weather GROUP BY zip_code HAVING avg(mean_humidity) < 70 INTERSECT SELECT zip_code FROM trip GROUP BY zip_code HAVING count(*) >= 100;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the names of stations that are located in Palo Alto city but have never been the ending point of trips more than 100 times?
SELECT name FROM station WHERE city = "Palo Alto" EXCEPT SELECT end_station_name FROM trip GROUP BY end_station_name HAVING count(*) > 100;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What are the names of the stations that are located in Palo Alto but have never been the ending point of the trips
SELECT name FROM station WHERE city = "Palo Alto" EXCEPT SELECT end_station_name FROM trip GROUP BY end_station_name HAVING count(*) > 100;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- How many trips started from Mountain View city and ended at Palo Alto city?
SELECT count(*) FROM station AS T1 JOIN trip AS T2 JOIN station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "Mountain View" AND T3.city = "Palo Alto";
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- How many trips stated from a station in Mountain View and ended at one in Palo Alto?
SELECT count(*) FROM station AS T1 JOIN trip AS T2 JOIN station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "Mountain View" AND T3.city = "Palo Alto";
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What is the average latitude and longitude of the starting points of all trips?
SELECT avg(T1.lat) , avg(T1.long) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id;
-- Database schema | station : id [ INT ] primary_key , name [ TEXT ] , lat [ INT ] , long [ INT ] , dock_count [ INT ] , city [ TEXT ] , installation_date [ TEXT ] | status : station_id [ INT ] status.station_id = station.id , bikes_available [ INT ] , docks_available [ INT ] , time [ TEXT ] | trip : id [ INT ] primary_key , duration [ INT ] , start_date [ TEXT ] , start_station_name [ TEXT ] , start_station_id [ INT ] , end_date [ TEXT ] , end_station_name [ TEXT ] , end_station_id [ INT ] , bike_id [ INT ] , subscription_type [ TEXT ] , zip_code [ INT ] | weather : date [ TEXT ] , max_temperature_f [ INT ] , mean_temperature_f [ INT ] , min_temperature_f [ INT ] , max_dew_point_f [ INT ] , mean_dew_point_f [ INT ] , min_dew_point_f [ INT ] , max_humidity [ INT ] , mean_humidity [ INT ] , min_humidity [ INT ] , max_sea_level_pressure_inches [ INT ] , mean_sea_level_pressure_inches [ INT ] , min_sea_level_pressure_inches [ INT ] , max_visibility_miles [ INT ] , mean_visibility_miles [ INT ] , min_visibility_miles [ INT ] , max_wind_Speed_mph [ INT ] , mean_wind_speed_mph [ INT ] , max_gust_speed_mph [ INT ] , precipitation_inches [ INT ] , cloud_cover [ INT ] , events [ TEXT ] , wind_dir_degrees [ INT ] , zip_code [ INT ] | -- -- What is the average latitude and longitude of all starting stations for the trips?
SELECT avg(T1.lat) , avg(T1.long) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- How many books are there?
SELECT count(*) FROM book;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- List the writers of the books in ascending alphabetical order.
SELECT Writer FROM book ORDER BY Writer ASC;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- List the titles of the books in ascending order of issues.
SELECT Title FROM book ORDER BY Issues ASC;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- What are the titles of the books whose writer is not "Elaine Lee"?
SELECT Title FROM book WHERE Writer != "Elaine Lee";
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- What are the title and issues of the books?
SELECT Title , Issues FROM book;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- What are the dates of publications in descending order of price?
SELECT Publication_Date FROM publication ORDER BY Price DESC;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- What are the distinct publishers of publications with price higher than 5000000?
SELECT DISTINCT Publisher FROM publication WHERE Price > 5000000;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- List the publisher of the publication with the highest price.
SELECT Publisher FROM publication ORDER BY Price DESC LIMIT 1;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- List the publication dates of publications with 3 lowest prices.
SELECT Publication_Date FROM publication ORDER BY Price ASC LIMIT 3;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show the title and publication dates of books.
SELECT T1.Title , T2.Publication_Date FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show writers who have published a book with price more than 4000000.
SELECT T1.Writer FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID WHERE T2.Price > 4000000;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show the titles of books in descending order of publication price.
SELECT T1.Title FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID ORDER BY T2.Price DESC;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show publishers that have more than one publication.
SELECT Publisher FROM publication GROUP BY Publisher HAVING COUNT(*) > 1;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show different publishers together with the number of publications they have.
SELECT Publisher , COUNT(*) FROM publication GROUP BY Publisher;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Please show the most common publication date.
SELECT Publication_Date FROM publication GROUP BY Publication_Date ORDER BY COUNT(*) DESC LIMIT 1;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- List the writers who have written more than one book.
SELECT Writer FROM book GROUP BY Writer HAVING COUNT(*) > 1;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- List the titles of books that are not published.
SELECT Title FROM book WHERE Book_ID NOT IN (SELECT Book_ID FROM publication);
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show the publishers that have publications with price higher than 10000000 and publications with price lower than 5000000.
SELECT Publisher FROM publication WHERE Price > 10000000 INTERSECT SELECT Publisher FROM publication WHERE Price < 5000000;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- What is the number of distinct publication dates?
SELECT COUNT (DISTINCT Publication_Date) FROM publication;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- How many distinct publication dates are there in our record?
SELECT COUNT (DISTINCT Publication_Date) FROM publication;
-- Database schema | publication : Publication_ID [ INT ] primary_key , Book_ID [ INT ] publication.Book_ID = book.Book_ID , Publisher [ TEXT ] , Publication_Date [ TEXT ] , Price [ INT ] | book : Book_ID [ INT ] primary_key , Title [ TEXT ] , Issues [ INT ] , Writer [ TEXT ] | -- -- Show the prices of publications whose publisher is either "Person" or "Wiley"
SELECT Price FROM publication WHERE Publisher = "Person" OR Publisher = "Wiley";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- How many actors are there?
SELECT count(*) FROM actor;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Count the number of actors.
SELECT count(*) FROM actor;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- List the name of actors in ascending alphabetical order.
SELECT Name FROM actor ORDER BY Name ASC;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of actors, ordered alphabetically?
SELECT Name FROM actor ORDER BY Name ASC;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the characters and duration of actors?
SELECT Character , Duration FROM actor;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Return the characters and durations for each actor.
SELECT Character , Duration FROM actor;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- List the name of actors whose age is not 20.
SELECT Name FROM actor WHERE Age != 20;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of actors who are not 20 years old?
SELECT Name FROM actor WHERE Age != 20;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the characters of actors in descending order of age?
SELECT Character FROM actor ORDER BY age DESC;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Return the characters for actors, ordered by age descending.
SELECT Character FROM actor ORDER BY age DESC;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What is the duration of the oldest actor?
SELECT Duration FROM actor ORDER BY Age DESC LIMIT 1;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Return the duration of the actor with the greatest age.
SELECT Duration FROM actor ORDER BY Age DESC LIMIT 1;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of musicals with nominee "Bob Fosse"?
SELECT Name FROM musical WHERE Nominee = "Bob Fosse";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Return the names of musicals who have the nominee Bob Fosse.
SELECT Name FROM musical WHERE Nominee = "Bob Fosse";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the distinct nominees of the musicals with the award that is not "Tony Award"?
SELECT DISTINCT Nominee FROM musical WHERE Award != "Tony Award";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Return the different nominees of musicals that have an award that is not the Tony Award.
SELECT DISTINCT Nominee FROM musical WHERE Award != "Tony Award";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show names of actors and names of musicals they are in.
SELECT T1.Name , T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of actors and the musicals that they are in?
SELECT T1.Name , T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show names of actors that have appeared in musical with name "The Phantom of the Opera".
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID WHERE T2.Name = "The Phantom of the Opera";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of actors who have been in the musical titled The Phantom of the Opera?
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID WHERE T2.Name = "The Phantom of the Opera";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show names of actors in descending order of the year their musical is awarded.
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of actors ordered descending by the year in which their musical was awarded?
SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show names of musicals and the number of actors who have appeared in the musicals.
SELECT T2.Name , COUNT(*) FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- How many actors have appeared in each musical?
SELECT T2.Name , COUNT(*) FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show names of musicals which have at least three actors.
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;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of musicals who have at 3 or more actors?
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;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show different nominees and the number of musicals they have been nominated.
SELECT Nominee , COUNT(*) FROM musical GROUP BY Nominee;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- How many musicals has each nominee been nominated for?
SELECT Nominee , COUNT(*) FROM musical GROUP BY Nominee;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Please show the nominee who has been nominated the greatest number of times.
SELECT Nominee FROM musical GROUP BY Nominee ORDER BY COUNT(*) DESC LIMIT 1;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Who is the nominee who has been nominated for the most musicals?
SELECT Nominee FROM musical GROUP BY Nominee ORDER BY COUNT(*) DESC LIMIT 1;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- List the most common result of the musicals.
SELECT RESULT FROM musical GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Return the most frequent result across all musicals.
SELECT RESULT FROM musical GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- List the nominees that have been nominated more than two musicals.
SELECT Nominee FROM musical GROUP BY Nominee HAVING COUNT(*) > 2;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Who are the nominees who have been nominated more than two times?
SELECT Nominee FROM musical GROUP BY Nominee HAVING COUNT(*) > 2;
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- List the name of musicals that do not have actors.
SELECT Name FROM musical WHERE Musical_ID NOT IN (SELECT Musical_ID FROM actor);
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- What are the names of musicals who have no actors?
SELECT Name FROM musical WHERE Musical_ID NOT IN (SELECT Musical_ID FROM actor);
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show the nominees that have nominated musicals for both "Tony Award" and "Drama Desk Award".
SELECT Nominee FROM musical WHERE Award = "Tony Award" INTERSECT SELECT Nominee FROM musical WHERE Award = "Drama Desk Award";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Who are the nominees who have been nominated for both a Tony Award and a Drama Desk Award?
SELECT Nominee FROM musical WHERE Award = "Tony Award" INTERSECT SELECT Nominee FROM musical WHERE Award = "Drama Desk Award";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Show the musical nominee with award "Bob Fosse" or "Cleavant Derricks".
SELECT Nominee FROM musical WHERE Award = "Tony Award" OR Award = "Cleavant Derricks";
-- Database schema | musical : Musical_ID [ INT ] primary_key , Name [ TEXT ] , Year [ INT ] , Award [ TEXT ] , Category [ TEXT ] , Nominee [ TEXT ] , Result [ TEXT ] | actor : Actor_ID [ INT ] primary_key , Name [ TEXT ] , Musical_ID [ INT ] actor.Musical_ID = actor.Actor_ID , Character [ TEXT ] , Duration [ TEXT ] , age [ INT ] | -- -- Who are the nominees who were nominated for either of the Bob Fosse or Cleavant Derricks awards?
SELECT Nominee FROM musical WHERE Award = "Tony Award" OR Award = "Cleavant Derricks";
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the emails of the user named "Mary".
SELECT email FROM user_profiles WHERE name = 'Mary';
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- What is the partition id of the user named "Iron Man".
SELECT partitionid FROM user_profiles WHERE name = 'Iron Man';
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- How many users are there?
SELECT count(*) FROM user_profiles;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- How many followers does each user have?
SELECT count(*) FROM follows;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the number of followers for each user.
SELECT count(*) FROM follows GROUP BY f1;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the number of tweets in record.
SELECT count(*) FROM tweets;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the number of users who posted some tweets.
SELECT count(DISTINCT UID) FROM tweets;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name and email of the user whose name contains the word ‘Swift’.
SELECT name , email FROM user_profiles WHERE name LIKE '%Swift%';
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the names of users whose emails contain ‘superstar’ or ‘edu’.
SELECT name FROM user_profiles WHERE email LIKE '%superstar%' OR email LIKE '%edu%';
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Return the text of tweets about the topic 'intern'.
SELECT text FROM tweets WHERE text LIKE '%intern%';
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name and email of the users who have more than 1000 followers.
SELECT name , email FROM user_profiles WHERE followers > 1000;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the names of the users whose number of followers is greater than that of the user named "Tyler Swift".
SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING count(*) > (SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 WHERE T1.name = 'Tyler Swift');
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name and email for the users who have more than one follower.
SELECT T1.name , T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING count(*) > 1;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the names of users who have more than one tweet.
SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING count(*) > 1;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the id of users who are followed by Mary and Susan.
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Mary" INTERSECT SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Susan";
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the id of users who are followed by Mary or Susan.
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Mary" OR T1.name = "Susan";
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name of the user who has the largest number of followers.
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name and email of the user followed by the least number of people.
SELECT name , email FROM user_profiles ORDER BY followers LIMIT 1;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- List the name and number of followers for each user, and sort the results by the number of followers in descending order.
SELECT name , followers FROM user_profiles ORDER BY followers DESC;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- List the names of 5 users followed by the largest number of other users.
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 5;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- List the text of all tweets in the order of date.
SELECT text FROM tweets ORDER BY createdate;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name of each user and number of tweets tweeted by each of them.
SELECT T1.name , count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name and partition id for users who tweeted less than twice.
SELECT T1.name , T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING count(*) < 2;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the name of the user who tweeted more than once, and number of tweets tweeted by them.
SELECT T1.name , count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING count(*) > 1;
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the average number of followers for the users who do not have any tweet.
SELECT avg(followers) FROM user_profiles WHERE UID NOT IN (SELECT UID FROM tweets);
-- Database schema | follows : f1 [ INT ] primary_key follows.f1 = user_profiles.uid , f2 [ INT ] follows.f2 = user_profiles.uid | tweets : id [ INT ] primary_key , uid [ INT ] tweets.uid = user_profiles.uid , text [ TEXT ] , createdate [ TEXT ] | user_profiles : uid [ INT ] primary_key , name [ TEXT ] , email [ TEXT ] , partitionid [ INT ] , followers [ INT ] | -- -- Find the average number of followers for the users who had some tweets.
SELECT avg(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets);