input
stringlengths
358
16.1k
output
stringlengths
24
805
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Among the users who use SUGAR, calculate the percentage of those who are above 20 years old. [/INST]
SELECT SUM(IIF(T1.age > 20, 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'SUGAR';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Indicate the location of all the events that occurred on April 30, 2016. [/INST]
SELECT longitude, latitude FROM events WHERE date(timestamp) = '2016-04-30';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many different models does the HTC brand have? [/INST]
SELECT COUNT(device_model) FROM phone_brand_device_model2 WHERE phone_brand = 'HTC';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Identify all installed and activated apps by their id. [/INST]
SELECT app_id FROM app_events WHERE is_active = 1 AND is_installed = 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many apps are labeled 7? [/INST]
SELECT COUNT(app_id) FROM app_labels WHERE label_id = 7;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Identify by their id all the devices that are used by women who are in the age range of 29 to 31 years. [/INST]
SELECT device_id FROM gender_age_train WHERE age BETWEEN 29 AND 31 AND gender = 'F';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Identify by their id all the apps that belong to the game-stress reliever category. [/INST]
SELECT T2.app_id FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'game-stress reliever';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: On what date were the most events logged on devices for 40-year-old male users? [/INST]
SELECT T.timestamp FROM ( SELECT T2.timestamp, COUNT(T2.event_id) AS num FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'M' AND T1.age = 40 GROUP BY T2.timestamp ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: On which brand of phone are the most applications installed? [/INST]
SELECT T.phone_brand FROM ( SELECT T1.phone_brand, COUNT(T4.is_active) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id INNER JOIN events_relevant AS T3 ON T2.device_id = T3.device_id INNER JOIN app_events_relevant AS T4 ON T3.event_id = T4.event_id WHERE T4.is_active = 1 GROUP BY T1.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many men under the age of 23 have apps installed but are not active on their devices? [/INST]
SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id INNER JOIN app_events_relevant AS T3 ON T2.event_id = T3.event_id WHERE T1.gender = 'M' AND T3.is_active = 0 AND T1.age < 23;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many women have apps from the game-Finding fault category installed on their device? [/INST]
SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id INNER JOIN app_events_relevant AS T3 ON T2.event_id = T3.event_id WHERE T1.age < 23 AND T1.gender = 'F' AND T3.is_active = 0 AND T3.is_installed = 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Which gender logged in the most to an event in the first 10 days of May 2016? [/INST]
SELECT T.gender FROM ( SELECT T1.gender, COUNT(T1.device_id) AS num FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE date(T2.timestamp) BETWEEN '2016-05-01' AND '2016-05-10' GROUP BY T1.gender ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What age group is the most using SM-T2558 model phones? [/INST]
SELECT T.`group` FROM ( SELECT T1.`group`, COUNT(T1.device_id) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'SM-T2558' GROUP BY T1.`group` ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many people over the age of 50 do not have HTC One M8 Eye phones? [/INST]
SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.age > 50 AND T2.device_model != 'One M8 Eye' AND T2.phone_brand != 'HTC';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Locate all events on devices of women under 30 years old. [/INST]
SELECT T1.device_id FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' AND T1.age < 30;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What percentage of women do not have applications installed on their mobile with respect to men? [/INST]
SELECT SUM(IIF(T1.gender = 'F', 1, 0)) / SUM(IIF(T1.gender = 'M', 1, 0)) AS per FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id INNER JOIN app_events_relevant AS T3 ON T2.event_id = T3.event_id WHERE T3.is_installed = 0;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Calculate the average age of people who have apps installed but are not active on their devices. [/INST]
SELECT AVG(T1.age) FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id INNER JOIN app_events_relevant AS T3 ON T2.event_id = T3.event_id WHERE T3.is_installed = 1 AND T3.is_active = 0;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please list any three events that happened on the 1st of May 2016 that have the same latitude of 31. [/INST]
SELECT event_id FROM events WHERE timestamp LIKE '2016-05-01%' AND latitude = 31 LIMIT 3;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please list any three events that have the longitude and latitude of 0. [/INST]
SELECT event_id FROM events WHERE longitude = 0 AND latitude = 0 LIMIT 3;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What is the difference between the events of device number -9222956879900150000 that can be located and those that are unable to be located? [/INST]
SELECT SUM(IIF(latitude != 0 AND longitude != 0, 1, 0)) - SUM(IIF(latitude = 0 AND longitude = 0, 1, 0)) AS diff FROM events WHERE device_id = '-922956879900150000';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please list any three devices that are owned by female users. [/INST]
SELECT device_id FROM gender_age WHERE gender = 'F' LIMIT 3;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please list any five app categories that are related to games, along with their label ID. [/INST]
SELECT category, label_id FROM label_categories WHERE category LIKE '%game%' LIMIT 5;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please list any three OPPO device models. [/INST]
SELECT device_model FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO' LIMIT 3;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What is the percentage of users who experienced event number 6 who have the app installed but do not use the app? [/INST]
SELECT SUM(IIF(is_installed = 1 AND is_active = 0, 1, 0)) / COUNT(app_id) AS perrcent FROM app_events WHERE event_id = 6;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Which gender owned more of the Galaxy Note 2 device model? [/INST]
SELECT IIF(SUM(IIF(T1.gender = 'M', 1, 0)) - SUM(IIF(T1.gender = 'F', 1, 0)) > 0, 'M', 'F') AS gender FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 2';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: When did event number 2 happen and how many users were active? [/INST]
SELECT COUNT(T1.app_id) AS num FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE T1.event_id = 2 AND T1.is_active = 1 GROUP BY T2.timestamp;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Which behavior category does user number 5902120154267990000 belong to? [/INST]
SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T2.app_id = 5902120154267990000;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many users belong to the same behavior category as comics? [/INST]
SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id WHERE T1.category = 'comics';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What is the age and gender of the person who uses the device number 29182687948017100 on event number 1? [/INST]
SELECT T1.age, T1.gender FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T1.device_id = 29182687948017100 AND T2.event_id = 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many male users have the log of events at the same longitude of 114? [/INST]
SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T2.longitude = 114 AND T1.gender = 'M';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: When did event number 7 happen for user number -8022267440849930000? [/INST]
SELECT T1.timestamp FROM events_relevant AS T1 INNER JOIN app_events AS T2 ON T1.event_id = T2.event_id WHERE T2.app_id = -8022267440849930000 AND T1.event_id = 7;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What are the behavior categories that user number -9222198347540750000 belongs to? [/INST]
SELECT T3.category FROM app_all AS T1 INNER JOIN app_labels AS T2 ON T1.app_id = T2.app_id INNER JOIN label_categories AS T3 ON T2.label_id = T3.label_id WHERE T1.app_id = -9222198347540750000;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please provide the age group of any LG Nexus 4 device users. [/INST]
SELECT T1.`group` FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'LG' AND T2.device_model = 'Nexus 4';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Please provide the gender of at least one user who owns an HTC Desire 826 device. [/INST]
SELECT T1.gender FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Desire 826' AND T2.phone_brand = 'HTC';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What is the percentage of users who are in the same behavior category as "Academic Information"? [/INST]
SELECT SUM(IIF(T1.category = 'Academic Information', 1.0, 0)) / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What is the percentage of device users in the F27-28 age group who experienced an event on the 3rd of May 2016? [/INST]
SELECT SUM(IIF(T1.`group` = 'F27-28', 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE SUBSTR(T2.timestamp, 1, 10) = '2016-05-03';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many OPPO devices are there? [/INST]
SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What is the most common age group among all device users? [/INST]
SELECT T.num FROM ( SELECT `group`, COUNT(`group`) AS num FROM gender_age GROUP BY `group` ) T;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many events does the device "4069764298338760000" have? [/INST]
SELECT COUNT(event_id) FROM events WHERE device_id = 4069764298338760000;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many of the apps belong in the "Equity Fund" category? [/INST]
SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T1.label_id = T2.label_id WHERE T2.category = 'Equity Fund';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: List all females aged 24 to 26 devices' locations. [/INST]
SELECT T2.longitude, T2.latitude FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T1.`group` = 'F24-26' AND T1.gender = 'F';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: How many male users have a Galaxy Note 3? [/INST]
SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 3' AND T1.gender = 'M';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: List all the devices' brands and models of events on 5/7/2016 at 6:03:22 AM. [/INST]
SELECT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-07 06:03:22';
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: Which brand is most common among people in their twenties? [/INST]
SELECT T.phone_brand FROM ( SELECT T2.phone_brand, COUNT(T2.phone_brand) AS num FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.age BETWEEN 20 AND 30 GROUP BY T2.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_all : app_id [ INTEGER ] primary_key app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] app_events_relevant : event_id [ INTEGER ] app_events_relevant.event_id = events_relevant.event_id app_id [ INTEGER ] app_events_relevant.app_id = app_all.app_id is_installed [ bool ] is_active [ bool ] app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] events_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] gender_age_test : device_id [ INTEGER ] primary_key gender_age_train : device_id [ INTEGER ] primary_key gender [ TEXT ] age [ INTEGER ] group [ TEXT ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] sample_submission : device_id [ INTEGER ] primary_key F23- [ REAL ] F24-26 [ REAL ] F27-28 [ REAL ] F29-32 [ REAL ] F33-42 [ REAL ] F43+ [ REAL ] M22- [ REAL ] M23-26 [ REAL ] M27-28 [ REAL ] M29-31 [ REAL ] M32-38 [ REAL ] M39+ [ REAL ] Please write me a SQL statement that answers the following question: What percentage of vivo devices belong to users with no information? [/INST]
SELECT SUM(IIF(T1.gender IS NULL AND T1.age IS NULL AND T1.`group` IS NULL, 1, 0)) / COUNT(T1.device_id) AS per FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.phone_brand = 'vivo';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Please list all the keywords of the episode "Refuge: Part 1". [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Refuge: Part 1';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many keywords are there for season 9, episode 23 of law_and_order? [/INST]
SELECT COUNT(T2.keyword) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.season = 9 AND T1.episode = 23;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the title of the episode with the keyword "laundering money"? [/INST]
SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword = 'laundering money';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Please list all the keywords for the episodes with a rating of over 8. [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.rating > 8;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many 10-star votes were given to the episode titled "Cherished"? [/INST]
SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' AND T2.stars = 10;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many votes did the episode titled "Cherished" get in total? [/INST]
SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the title of the episode that got the most 10-star votes? [/INST]
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 ORDER BY T2.votes DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Park Dietz was credited in which role in the episode titled "Cherished"? [/INST]
SELECT T2.role FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T3.name = 'Park Dietz' AND T2.credited = 'true';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many people had filled a role in the episode titled "Cherished", but did not show up in the on-screen credits? [/INST]
SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' AND T2.credited = 'false';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who was credited as "technical advisor" in the episode titled "Cherished"? [/INST]
SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T2.credited = 'true' AND T2.role = 'technical advisor';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: For how many times was Park Dietz credited? [/INST]
SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Please list the titles of all the episodes in which Park Dietz was credited. [/INST]
SELECT T1.title FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Was Anthony Azzara's role in episode tt0629204 displayed in the credits at the end of the episode? [/INST]
SELECT T1.credited FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Anthony Azzara' AND T1.episode_id = 'tt0629204';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many keywords are there in the episode Disciple? [/INST]
SELECT COUNT(T2.keyword) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Disciple';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Which episode got the most 1 star votes? Give its title. [/INST]
SELECT T2.title FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 1 ORDER BY T1.votes DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many nominations did Law and Order season 9, episode 20 get? [/INST]
SELECT COUNT(T2.award_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.series = 'Law and Order' AND T1.season = 9 AND T1.episode = 20;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: For season 9, episode 17 of the show Law and Order, how many roles have been included in the credit? [/INST]
SELECT COUNT(T2.role) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.series = 'Law and Order' AND T1.season = 9 AND T1.episode = 17 AND T2.credited = 'true';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Describe what happened in the episode of award no.296. [/INST]
SELECT T1.summary FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.award_id = 296;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Which role did Joseph Blair play in the show? [/INST]
SELECT T1.role FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Joseph Blair';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many awards has Rene Balcer been nominated for? [/INST]
SELECT COUNT(T2.award_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Rene Balcer';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: For the episode with the most votes, give its air date. [/INST]
SELECT T2.air_date FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id GROUP BY T2.episode_id ORDER BY SUM(T1.votes) DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who was nominated for award no.313? Give the full name. [/INST]
SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.award_id = 313;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many episodes did J.K. Simmons' role appear on the show? [/INST]
SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'J.K. Simmons';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Display the number of 9-star votes the episode Sideshow received. [/INST]
SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 9 AND T1.title = 'Sideshow';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many times is the number of keywords in "Refuge: Part 1" episode than "Shield" episode? [/INST]
SELECT CAST(SUM(CASE WHEN T1.title = 'Refuge: Part 1' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.title = 'Shield' THEN 1 ELSE 0 END) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Calculate the average number of cast members that appeared in the credit from the 185th to the 193rd episode. [/INST]
SELECT CAST(COUNT(T1.episode_id) AS REAL) / (193 - 185 + 1) FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.category = 'Cast' AND T1.credited = 'true' AND T2.number_in_series BETWEEN 185 AND 193;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What are the names of the person that were not credited at the end of episode tt0629391? [/INST]
SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.credited = 'false' AND T1.episode_id = 'tt0629391';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many people have won at least 3 awards? [/INST]
SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.result = 'Winner' GROUP BY T1.person_id HAVING COUNT(T2.award_id) >= 3;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the script supervisor of the series in episode tt0629204? [/INST]
SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.episode_id = 'tt0629204' AND T1.role = 'script supervisor';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many awards has Julia Roberts been nominated for? [/INST]
SELECT COUNT(T2.award_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Julia Roberts' AND T2.result = 'Nominee';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the tallest camera operator? [/INST]
SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'camera operator' ORDER BY T2.height_meters DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many people, who were born in Canada, won an award in 1999? [/INST]
SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T2.year = 1999 AND T1.birth_country = 'Canada';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many people gave the most enjoyed episode a 10-star rating? [/INST]
SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What are the keywords of the "Shield" episode? [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Shield';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the percentage of people who gave the "True North" episode a 1-star rating? [/INST]
SELECT CAST(SUM(CASE WHEN T2.stars = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'True North' AND T1.episode_id = 'tt0629477';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the title of the episode with the highest number of keywords? [/INST]
SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id GROUP BY T1.episode_id ORDER BY COUNT(T2.keyword) DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Among the episodes that were aired in 1998, how many won an International Monitor Awards? [/INST]
SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE strftime('%Y', T1.air_date) = '1998' AND T2.organization = 'International Monitor Awards' AND T2.result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many times did the episode titled "Agony" win an award? [/INST]
SELECT COUNT(T2.award_id) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Agony' AND T2.result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many episodes are there in the 9th season of Law and Order? Calculate the average number of casts per season of the said series. [/INST]
SELECT SUM(CASE WHEN T2.season = 9 THEN 1 ELSE 0 END) AS num , CAST(SUM(CASE WHEN T2.season = 9 THEN 1 ELSE 0 END) AS REAL) / COUNT(T1.episode_id) FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.category = 'Cast' AND T2.series = 'Law and Order';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What are the keywords of the episode which received the 2nd-highest number of votes? [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.votes NOT IN ( SELECT MAX(T1.votes) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id ) ORDER BY T1.votes DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many awards did the "Agony" win? [/INST]
SELECT COUNT(T2.award) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Agony' AND T2.result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the narrator of the "Flight" episode? [/INST]
SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Flight' AND T2.role = 'Narrator';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: In which organization did Constantine Makris win the most awards? [/INST]
SELECT T2.organization FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.name = 'Constantine Makris' AND T2.result = 'Winner' GROUP BY T2.organization ORDER BY COUNT(T2.award_id) DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the stunt coordinator in episode 3? [/INST]
SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.episode = 3 AND T2.role = 'stunt coordinator';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many people were not credited at the end of the "Admissions" episode? [/INST]
SELECT COUNT(T2.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Admissions' AND T2.credited = 'false';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the title of the episode that has the highest number of crews in the Art Department? [/INST]
SELECT T2.title FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.category = 'Art Department' GROUP BY T2.episode_id ORDER BY COUNT(T1.category) DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many roles did Julia Roberts play in the series? [/INST]
SELECT COUNT(T1.role) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Julia Roberts';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What are the titles of the top 3 episodes that received no less than 30 votes in its 10-star rating? [/INST]
SELECT T2.title FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.votes >= 30 AND T1.stars = 10 ORDER BY T1.votes DESC LIMIT 3;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the youngest person to ever play a "clerk" role in the series? [/INST]
SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.role = 'Clerk' AND T2.birthdate IS NOT NULL ORDER BY T2.birthdate LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many people did not enjoy the finale episode? [/INST]
SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode = 24 AND T2.stars = 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: List the names of all the cast members in the series. [/INST]
SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.category = 'Cast';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the person who appeared the most in the series? Calculate in percentage how many times he or she appeared. [/INST]
SELECT T2.person_id, CAST(COUNT(T2.person_id) AS REAL) * 100 / ( SELECT COUNT(T2.person_id) AS num FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id ) AS per FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id GROUP BY T2.person_id ORDER BY COUNT(T2.person_id) DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Which episodes of the Law & Order have been nominated for the Primetime Emmy Awards? [/INST]
SELECT DISTINCT episode_id FROM Award WHERE award_category = 'Primetime Emmy';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many episodes have not won any Law & Order series awards? [/INST]
SELECT COUNT(award_id) FROM Award WHERE Result = 'Nominee';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key series [ TEXT ] season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ DATE ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Person : person_id [ TEXT ] primary_key name [ TEXT ] birthdate [ DATE ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] series [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id person_id [ TEXT ] Award.person_id = Person.person_id role [ TEXT ] result [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id person_id [ TEXT ] Credit.person_id = Person.person_id category [ TEXT ] role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What roles have not been credited at the end of the episodes? [/INST]
SELECT DISTINCT role FROM Credit WHERE credited = 'false';