input
stringlengths
358
16.1k
output
stringlengths
24
805
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the names of the films released in 2003 among the films scored by user 2941 . [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_release_year = 2003 AND T1.user_id = 2941;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: How many users were not trialists when they rated the movie "Patti Smith: Dream of Life"? [/INST]
SELECT COUNT(T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'Patti Smith: Dream of Life' AND T1.user_trialist = 0;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which movie has the highest average score in Mubi? [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id GROUP BY T2.movie_title ORDER BY SUM(T1.rating_score) / COUNT(T1.rating_id) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the names of the top three movies in the number comments related to the critic made by the user rating the movie. [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.critic_comments DESC LIMIT 3;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What was the title of the first list created by a user 85981819? And please provide the user_avatar_image_url. [/INST]
SELECT T2.list_title, T1.user_avatar_image_url FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T1.user_id = 85981819 ORDER BY T2.list_creation_timestamp_utc LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the names of the movies that have been rated the most times in 2020. [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_timestamp_utc LIKE '2020%' GROUP BY T2.movie_title ORDER BY COUNT(T2.movie_title) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average score for the movie Versailles Rive-Gauche? [/INST]
SELECT AVG(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title LIKE 'Versailles Rive-Gauche';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which film rated by user 59988436 that received 21 comments? [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.user_id = 59988436 AND T1.critic_comments = 21;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the names of the movies that received more than 20 likes? [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.critic_likes > 20;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average score of the movie "The Fall of Berlin" in 2019? [/INST]
SELECT SUM(T1.rating_score) / COUNT(T1.rating_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_timestamp_utc LIKE '2019%' AND T2.movie_title LIKE 'The Fall of Berlin';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What percentage of users rated the movie "Patti Smith: Dream of Life" by more than 3? [/INST]
SELECT CAST(SUM(CASE WHEN T1.rating_score > 3 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title LIKE 'Patti Smith: Dream of Life';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which of the film directed by director Abbas Kiarostami has the highest average score? [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.director_name = 'Abbas Kiarostami' GROUP BY T2.movie_title ORDER BY SUM(T1.rating_score) / COUNT(T1.rating_id) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which year had the most released films? [/INST]
SELECT movie_release_year FROM movies GROUP BY movie_release_year ORDER BY COUNT(movie_id) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who is the director that made the most movies? Give the director's id. [/INST]
SELECT director_id FROM movies GROUP BY director_id ORDER BY COUNT(movie_id) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: How many movies did the director of the highest movie popularity make? [/INST]
SELECT COUNT(movie_id) FROM movies WHERE director_id = ( SELECT director_id FROM movies ORDER BY movie_popularity DESC LIMIT 1 );
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What's the number of the paying subscribers when rating a movie after the year 2014? [/INST]
SELECT COUNT(user_subscriber) FROM ratings_users WHERE user_has_payment_method = 1 AND rating_date_utc > '2014%';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who was the earliest user created a list but didn't get any followers? Give the user ID. [/INST]
SELECT user_id FROM lists_users WHERE user_subscriber = 0 ORDER BY list_creation_date_utc LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Give the number of followers for the user who posted the most lists. [/INST]
SELECT SUM(T1.list_followers) FROM lists AS T1 INNER JOIN lists_users AS T2 ON T1.list_id = T2.list_id GROUP BY T1.user_id ORDER BY COUNT(T1.list_id) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: How many followers did the user who posted the list "Non-American Films about World War II" have? [/INST]
SELECT SUM(T2.list_followers) FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_title LIKE 'Non-American Films about World War II';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What's the number of users gave the movie "Downfall" a rating of "4"? [/INST]
SELECT COUNT(T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'Downfall' AND T1.rating_score = 4;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Give the name of the movie that got the most "5" ratings. [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_score = 5;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which movie got the most critic comments? Give the name of the movie. [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id GROUP BY T2.movie_title ORDER BY COUNT(T1.critic_comments) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Show the avatar of the user who gave the rating at 2019/10/17 1:36:36. [/INST]
SELECT T2.user_avatar_image_url FROM ratings AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id WHERE T1.rating_timestamp_utc LIKE '2019-10-17 01:36:36';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Show the portrait picture of the user who created the list "Vladimir Vladimirovich Nabokov". [/INST]
SELECT T1.user_avatar_image_url FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_title LIKE 'Vladimir Vladimirovich Nabokov';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For the user who post the list that contained the most number of the movies, is he/she a paying subscriber when creating that list? [/INST]
SELECT T1.user_has_payment_method FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_movie_number = ( SELECT MAX(list_movie_number) FROM lists );
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Show the head portrait of the user who gave the most "5" ratings. [/INST]
SELECT T2.user_avatar_image_url FROM ratings AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id WHERE T1.rating_score = 5;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: How many critics were given to the movie that got the most movie popularity number. [/INST]
SELECT COUNT(T1.critic) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_popularity = ( SELECT MAX(movie_popularity) FROM movies );
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who gave a "4" rating to the movie "Freaks" at 2013/5/4 6:33:32? Give his/her user id. [/INST]
SELECT T1.user_id FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE rating_score = 4 AND rating_timestamp_utc LIKE '2013-05-04 06:33:32' AND T2.movie_title LIKE 'Freaks';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Give the url of movie which was rated 5 on 2013/5/3 5:11:17. [/INST]
SELECT T2.movie_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE rating_score = 5 AND rating_timestamp_utc LIKE '2013-05-03 05:11:17';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For the 1998 movie which got the highest popularity, how many "4" rating did the movie get? [/INST]
SELECT COUNT(T2.movie_title) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_score = 4 AND T2.movie_release_year = 1998 ORDER BY T2.movie_popularity DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: From all the movies that got more than 13000 popularity number, which one had the least ratings. [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_popularity > 13000 ORDER BY T1.rating_score LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: How many paying subscribers gave a rating to the movie "One Flew Over the Cuckoo's Nest"? [/INST]
SELECT COUNT(T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id INNER JOIN ratings_users AS T3 ON T1.user_id = T3.user_id WHERE T2.movie_title = 'One Flew Over the Cuckoo''s Nest' AND T3.user_has_payment_method = 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For the lists that got more than 3000 followers, how many did the users who created those lists are paying subscribers? [/INST]
SELECT COUNT(T1.user_id) FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_followers > 3000 AND T1.user_has_payment_method = 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which 1988 movie got the most ratings? [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_release_year = 1988 ORDER BY T1.rating_score DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For all the movies that were released in 1995, how many lower than 3 ratings did the most popularity movie had? [/INST]
SELECT COUNT(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.rating_score < 3 AND T2.movie_release_year = 1995 AND T2.movie_popularity = ( SELECT MAX(movie_popularity) FROM movies WHERE movie_release_year = 1995 );
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the percentage of users gave "5" to the movie "Go Go Tales"? [/INST]
SELECT CAST(SUM(CASE WHEN T1.rating_score = 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'Go Go Tales';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Give the percentage of subscribers who rated who rated the movie "G.I. Jane". [/INST]
SELECT CAST(SUM(CASE WHEN T3.user_subscriber = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id INNER JOIN lists_users AS T3 ON T1.user_id = T3.user_id WHERE T2.movie_title = 'G.I. Jane';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For all the users who gave "A Shot in the Dark" a rating, how many percent of them is a paying subscriber? [/INST]
SELECT CAST(SUM(CASE WHEN T1.user_has_payment_method = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id INNER JOIN lists_users AS T3 ON T1.user_id = T3.user_id WHERE T2.movie_title = 'A Shot in the Dark';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Name all the list titles created by user 4208563. [/INST]
SELECT list_title FROM lists WHERE user_id LIKE 4208563;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Among the lists created in 2016, which is the list that was updated most recently. [/INST]
SELECT list_title FROM lists WHERE strftime('%Y', list_update_timestamp_utc) = '2016' ORDER BY list_update_timestamp_utc DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the percentage of list created by user who was a subscriber when he created the list? [/INST]
SELECT CAST(SUM(CASE WHEN user_subscriber = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(list_id) FROM lists_users;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Name all lists created by a user who was a subcriber when created the list. [/INST]
SELECT DISTINCT T2.list_id FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T1.user_subscriber = 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Provide list titles created by user who are eligible for trial when he created the list. [/INST]
SELECT DISTINCT T2.list_title FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T1.user_eligible_for_trial = 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Among the lists with at least one follower, how many were created by user who was subscriber when created the list? [/INST]
SELECT COUNT(T1.list_id) FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_followers >= 1 AND T1.user_subscriber = 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For all list titles with at least 200 movies in the list, what is their average number of followers? [/INST]
SELECT AVG(list_followers) FROM lists WHERE list_movie_number > 200;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: List all the titles created by user who was a subsriber when he created the list and have less than 50 movies in the list. [/INST]
SELECT DISTINCT T2.list_title FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_movie_number < 50 AND T1.user_subscriber = 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Which title list has not been updated for the longest period of time? State how long it has not been updated? [/INST]
SELECT list_title , datetime(CURRENT_TIMESTAMP, 'localtime') - datetime(list_update_timestamp_utc) FROM lists ORDER BY list_update_timestamp_utc LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who is the user who created the list titled 'Sound and Vision'? Was he a subcriber when he created the list? [/INST]
SELECT T1.user_id, T1.user_subscriber FROM lists_users AS T1 INNER JOIN lists AS T2 ON T1.list_id = T2.list_id WHERE T2.list_title LIKE 'Sound and Vision';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: For the list with more than 200 followers, state the title and how long the list has been created? [/INST]
SELECT list_title , 365 * (strftime('%Y', 'now') - strftime('%Y', list_creation_timestamp_utc)) + 30 * (strftime('%m', 'now') - strftime('%m', list_creation_timestamp_utc)) + strftime('%d', 'now') - strftime('%d', list_creation_timestamp_utc) FROM lists WHERE list_followers > 200;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Among all movies in the list, calculate the percentage of movies that were never been rated? [/INST]
SELECT CAST(SUM(CASE WHEN T2.movie_id IS NULL THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.movie_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: List all movies rated by user 39115684. State the title, rating date and rating score. [/INST]
SELECT T2.movie_title, T1.rating_timestamp_utc, T1.rating_score FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.user_id = 39115684;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Between 1970 to 1980, how many movies with a popularity of more than 11,000 were released? [/INST]
SELECT COUNT(movie_id) FROM movies WHERE movie_release_year BETWEEN '1970' AND '1980' AND movie_popularity > 11000;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: How many movies directed by Felipe Cazals was realeased on 1976? [/INST]
SELECT COUNT(movie_id) FROM movies WHERE movie_release_year = 1976 AND director_name LIKE 'Felipe Cazals';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the URL to the movie director page on Mubi of the movie titled "Red Blooded American Girl" [/INST]
SELECT director_url FROM movies WHERE movie_title LIKE 'Red Blooded American Girl';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the list that was updated most recently? [/INST]
SELECT list_title FROM lists WHERE list_update_timestamp_utc = ( SELECT list_update_timestamp_utc FROM lists ORDER BY list_update_timestamp_utc DESC LIMIT 1 );
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who created the list that has 142 comments? Indicate the user id of the user, if there are multiple lists with 142 comments, list the user id of the person who created the list [/INST]
SELECT user_id FROM lists WHERE list_comments = 142;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is Jeannot Szwarc's most popular movie and what is its average rating score? [/INST]
SELECT T2.movie_title, AVG(T1.rating_score) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.director_name = 'Jeannot Szwarc' ORDER BY T2.movie_popularity DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who is the director that directed the highest number of movies in the 70s? If there are multiple directors with the same amount of movies, list all of their names and indicate the highest rating score that those movies got from the users. [/INST]
SELECT T2.director_name, T1.rating_score FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_release_year BETWEEN 1970 AND 1979 GROUP BY T2.director_id ORDER BY COUNT(T2.movie_id) DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Between 1/1/2010 to 12/31/2020, how many users, who were a trialist when they created the list, gave the movie "The Secret Life of Words" a rating score of 3? [/INST]
SELECT COUNT(T1.user_id) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'The Secret Life of Words' AND T1.rating_score = 3 AND T1.user_trialist = 0 AND T1.rating_timestamp_utc BETWEEN '2010%' AND '2020%';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the movie whose critic received the highest amount of likes? Indicate the URL to the rating on Mubi. [/INST]
SELECT T2.movie_title, T1.rating_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.critic_likes DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What are the top 5 most popular movies of the 21st century? Indicate how many users gave it a rating score of 5. [/INST]
SELECT DISTINCT T2.movie_id, SUM(T1.rating_score = 5) FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T2.movie_popularity DESC LIMIT 5;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average number of followers of the lists created by the user who rated the movie "Pavee Lackeen: The Traveller Girl" on 3/27/2011 at 2:06:34 AM? [/INST]
SELECT CAST(SUM(T4.list_followers) AS REAL) / COUNT(T2.list_id) FROM ratings AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id INNER JOIN movies AS T3 ON T1.movie_id = T3.movie_id INNER JOIN lists AS T4 ON T2.list_id = T4.list_id WHERE T3.movie_title LIKE 'Pavee Lackeen: The Traveller Girl' AND T1.rating_timestamp_utc LIKE '2011-03-27 02:06:34';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Between 1/1/2017 to 12/31/2017, how many users who were eligible for trial when they rated the movie "Patti Smith: Dream of Life"and what is the image URL to the movie on Mubi? [/INST]
SELECT COUNT(T1.user_id), T2.movie_image_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE datetime(T1.rating_timestamp_utc) BETWEEN '2017-01-01 00:00:00' AND '2017-12-31 00:00:00';
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average number of number of movies added to the lists of user 8516503? Indicate how many movies did he/she give a rating score of 5. [/INST]
SELECT AVG(T3.list_movie_number) , SUM(CASE WHEN T1.rating_score = 5 THEN 1 ELSE 0 END) FROM ratings AS T1 INNER JOIN lists_users AS T2 ON T1.user_id = T2.user_id INNER JOIN lists AS T3 ON T2.user_id = T3.user_id WHERE T1.user_id = 8516503;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: Who is the director of the most popular movie of all time and when was it released? Indicate the average rating score of the users who were on a trialist when they rated the movie. [/INST]
SELECT T1.director_name, T1.movie_release_year , SUM(T2.rating_score) / COUNT(T2.user_id) FROM movies AS T1 INNER JOIN ratings AS T2 ON T1.movie_id = T2.movie_id WHERE T2.user_trialist = 1 ORDER BY T1.movie_popularity DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the movie that was rated recently by user 57756708? [/INST]
SELECT T2.movie_title FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T1.user_id = 57756708 ORDER BY T1.rating_timestamp_utc DESC LIMIT 1;
[INST] Here is a database schema: lists : user_id [ INTEGER ] lists.user_id = lists_users.user_id list_id [ INTEGER ] primary_key list_title [ TEXT ] list_movie_number [ INTEGER ] list_update_timestamp_utc [ TEXT ] list_creation_timestamp_utc [ TEXT ] list_followers [ INTEGER ] list_url [ TEXT ] list_comments [ INTEGER ] list_description [ TEXT ] list_cover_image_url [ TEXT ] list_first_image_url [ TEXT ] list_second_image_url [ TEXT ] list_third_image_url [ TEXT ] movies : movie_id [ INTEGER ] primary_key movie_title [ TEXT ] movie_release_year [ INTEGER ] movie_url [ TEXT ] movie_title_language [ TEXT ] movie_popularity [ INTEGER ] movie_image_url [ TEXT ] director_id [ TEXT ] director_name [ TEXT ] director_url [ TEXT ] ratings_users : user_id [ INTEGER ] ratings_users.user_id = lists_users.user_id rating_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] lists_users : user_id [ INTEGER ] lists_users.user_id = lists.user_id list_id [ INTEGER ] lists_users.list_id = lists.list_id list_update_date_utc [ TEXT ] list_creation_date_utc [ TEXT ] user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_avatar_image_url [ TEXT ] user_cover_image_url [ TEXT ] user_eligible_for_trial [ TEXT ] user_has_payment_method [ TEXT ] ratings : movie_id [ INTEGER ] ratings.movie_id = movies.movie_id rating_id [ INTEGER ] rating_url [ TEXT ] rating_score [ INTEGER ] rating_timestamp_utc [ TEXT ] critic [ TEXT ] critic_likes [ INTEGER ] critic_comments [ INTEGER ] user_id [ INTEGER ] ratings.user_id = lists_users.user_id user_trialist [ INTEGER ] user_subscriber [ INTEGER ] user_eligible_for_trial [ INTEGER ] user_has_payment_method [ INTEGER ] Please write me a SQL statement that answers the following question: What are the top 10 oldest movies and what are the average rating score for each movie? Indicate the name of the director and when the movies were released. [/INST]
SELECT T2.movie_id, AVG(T1.rating_score), T2.director_name, T2.movie_release_year FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.rating_timestamp_utc ASC LIMIT 10;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which date has the most ordered quantity? What is the total order quantity on that day? [/INST]
SELECT ord_date, SUM(qty) FROM sales GROUP BY ord_date ORDER BY SUM(qty) DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the title with the most ordered quantity in year 1992? [/INST]
SELECT T2.title FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y', T1.ord_date) = '1992' ORDER BY T1.qty DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List the title, price and publication date for all sales with 'ON invoice' payment terms. [/INST]
SELECT T2.title, T2.price, T2.pubdate FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id WHERE T1.payterms = 'ON invoice';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the title that have at least 10% royalty without minimum range amount. [/INST]
SELECT T1.title FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.lorange = 0 AND T2.royalty >= 10;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: State the title and royalty percentage for title ID BU2075 between 10000 to 50000 range. [/INST]
SELECT T1.title, T2.royalty FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.lorange > 10000 AND T2.hirange < 50000 AND T1.title_ID = 'BU2075';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Among the titles with royalty percentage, which title has the greatest royalty percentage. State it's minimum range to enjoy this royalty percentage. [/INST]
SELECT T1.title, T2.lorange FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id ORDER BY T2.royalty DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Provide a list of titles together with its publisher name for all publishers located in the USA. [/INST]
SELECT T1.title, T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'USA';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: State the royalty percentage for the most year to date sale title within the 20000 range. [/INST]
SELECT MAX(T1.ytd_sales) FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.lorange > 20000 AND T2.hirange < 20000;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List all titles published in year 1991. Also provide notes details of the title and the publisher's name. [/INST]
SELECT T1.title, T1.notes, T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List all titles with sales of quantity more than 20 and store located in the CA state. [/INST]
SELECT T1.title, T2.qty FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN stores AS T3 ON T2.stor_id = T3.stor_id WHERE T2.qty > 20 AND T3.state = 'CA';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the store with the highest quantity in sales? What is the least quantity title from the store's sale? [/INST]
SELECT T3.stor_id, T2.title FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id INNER JOIN stores AS T3 ON T3.stor_id = T1.stor_id WHERE T3.stor_id = ( SELECT stor_id FROM sales GROUP BY stor_id ORDER BY SUM(qty) DESC LIMIT 1 ) GROUP BY T3.stor_id, T2.title ORDER BY SUM(T1.qty) ASC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the title and publisher for title ID BU 2075. Provide all the royalty percentage for all ranges. [/INST]
SELECT T1.title, T3.pub_name, T2.lorange, T2.hirange, T2.royalty FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T1.title_id = 'BU2075';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the store with ID 7066 and calculate the percentage of the the quantity ordered that were on 'Net 30' payment terms. [/INST]
SELECT T2.stor_name , CAST(SUM(CASE WHEN payterms = 'Net 30' THEN qty ELSE 0 END) AS REAL) * 100 / SUM(qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T1.stor_id = '7066' GROUP BY T2.stor_name;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: State the publisher name for publisher ID 877? Calculate its average year to date sales. [/INST]
SELECT T2.pub_name, AVG(T1.ytd_sales) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.pub_id = '0877' GROUP BY T2.pub_name;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name all employees who were hired before year 1990. [/INST]
SELECT fname, lname FROM employee WHERE STRFTIME('%Y', hire_date) < '1990';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Which employee has the lowest job level. State the first name, last name and when he /she was hired. [/INST]
SELECT fname, lname, hire_date FROM employee ORDER BY job_lvl LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: In which year has the most hired employees? [/INST]
SELECT STRFTIME('%Y', hire_date) FROM employee GROUP BY STRFTIME('%Y', hire_date) ORDER BY COUNT(emp_id) DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List all employees who are at the maximum level in their job designation. [/INST]
SELECT T1.fname, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl = T2.max_lvl;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the Chief Executive Officer and when he/she was hired. [/INST]
SELECT T1.fname, T1.lname, T1.hire_date FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T2.job_desc = 'Chief Financial Officier';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Who are the employees working for publisher not located in USA? State the employee's name and publisher name. [/INST]
SELECT T1.fname, T1.lname, T2.pub_name FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country != 'USA';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List all employees working for publisher 'GGG&G'. State their name and job description. [/INST]
SELECT T1.fname, T1.lname, T3.job_desc FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T1.job_id = T3.job_id WHERE T2.pub_name = 'GGG&G';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: For each publisher, state the type of titles they published order by the publisher name. [/INST]
SELECT DISTINCT T2.pub_name, T1.type FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T2.pub_name;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the publisher which has the most titles published in 1991. [/INST]
SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991' GROUP BY T1.pub_id, T2.pub_name ORDER BY COUNT(T1.title_id) DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name the title with the highest price published by 'Binnet & Hardley'. [/INST]
SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'Binnet & Hardley' ORDER BY T1.price DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Among all employees, who have job level greater than 200. State the employee name and job description. [/INST]
SELECT T1.fname, T1.lname, T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl > 200;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name all the authors for all business titles. [/INST]
SELECT T3.au_fname, T3.au_lname FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T1.type = 'business';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List all the titles and year to date sales by author who are not on contract. [/INST]
SELECT T1.title_id, T1.ytd_sales FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: For all authors from CA who are not on contract, which title of his/hers has the most year to date sales. [/INST]
SELECT T1.title FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0 AND T3.state = 'CA' ORDER BY T1.ytd_sales DESC LIMIT 1;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Name all the authors for 'Sushi, Anyone?'. [/INST]
SELECT T3.au_fname, T3.au_lname FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T1.title = 'Sushi, Anyone?';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the percentage of the employees who are Editor or Designer? [/INST]
SELECT CAST(SUM(CASE WHEN T2.job_desc IN ('Editor', 'Designer') THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id;
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: List all titles which have year to date sales higher than the average order by pubisher name. [/INST]
SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.ytd_sales > ( SELECT AVG(ytd_sales) FROM titles );
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: How many publishers are in the USA? [/INST]
SELECT COUNT(pub_id) FROM publishers WHERE country = 'USA';
[INST] Here is a database schema: authors : au_id [ TEXT ] primary_key au_lname [ TEXT ] au_fname [ TEXT ] phone [ TEXT ] address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] contract [ TEXT ] jobs : job_id [ INTEGER ] primary_key job_desc [ TEXT ] min_lvl [ INTEGER ] max_lvl [ INTEGER ] publishers : pub_id [ TEXT ] primary_key pub_name [ TEXT ] city [ TEXT ] state [ TEXT ] country [ TEXT ] employee : emp_id [ TEXT ] primary_key fname [ TEXT ] minit [ TEXT ] lname [ TEXT ] job_id [ INTEGER ] employee.job_id = jobs.job_id job_lvl [ INTEGER ] pub_id [ TEXT ] employee.pub_id = publishers.pub_id hire_date [ DATETIME ] pub_info : pub_id [ TEXT ] primary_key pub_info.pub_id = publishers.pub_id logo [ BLOB ] pr_info [ TEXT ] stores : stor_id [ TEXT ] primary_key stor_name [ TEXT ] stor_address [ TEXT ] city [ TEXT ] state [ TEXT ] zip [ TEXT ] discounts : discounttype [ TEXT ] stor_id [ TEXT ] discounts.stor_id = stores.stor_id lowqty [ INTEGER ] highqty [ INTEGER ] discount [ REAL ] titles : title_id [ TEXT ] primary_key title [ TEXT ] type [ TEXT ] pub_id [ TEXT ] titles.pub_id = publishers.pub_id price [ REAL ] advance [ REAL ] royalty [ INTEGER ] ytd_sales [ INTEGER ] notes [ TEXT ] pubdate [ DATETIME ] roysched : title_id [ TEXT ] roysched.title_id = titles.title_id lorange [ INTEGER ] hirange [ INTEGER ] royalty [ INTEGER ] sales : stor_id [ TEXT ] sales.stor_id = stores.stor_id ord_num [ TEXT ] ord_date [ DATETIME ] qty [ INTEGER ] payterms [ TEXT ] title_id [ TEXT ] sales.title_id = titles.title_id titleauthor : au_id [ TEXT ] titleauthor.au_id = authors.au_id title_id [ TEXT ] titleauthor.title_id = titles.title_id au_ord [ INTEGER ] royaltyper [ INTEGER ] Please write me a SQL statement that answers the following question: What is the publisher's information of New Moon Books? [/INST]
SELECT T1.pr_info FROM pub_info AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books';