1sf/bird-sql-train-with-schema huggingface dataset:
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: For the event which happened at 14:09:49 on 2016/5/6, in the location coordinate(116, 40), how many apps were active?
Evidence: at 14:09:49 on 2016/5/6 refers to timestamp = '2016/5/6 14:09:49'; location coordinate(116, 40) refers to longitude = '116' AND latitude = '40'; active refers to is_active = '1';
SQL: SELECT COUNT(T1.app_id) FROM app_events AS T1 INNER JOIN events AS T2 ON T1.event_id = T2.event_id WHERE T2.timestamp = '2016-05-06 14:09:49' AND T1.is_active = '1' AND T2.longitude = '116' AND T2.latitude = '40'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: How many times is the number of active apps in the event that happened at 7:50:28 on 2016/5/2 than in the event that happened at 7:41:03 on 2016/5/2?
Evidence: how many times = DIVIDE(SUM(IF(timestamp = '2016/5/2 7:50:28', 1,0)), SUM(IF(timestamp = '2016/5/2 7:41:03',1,0))); active refers to is_active = '1'; at 7:50:28 on 2016/5/2 refers to timestamp = '2016/5/2 7:50:28'; at 7:41:03 on 2016/5/2 refers to timestamp = '2016/5/2 7:41:03';
SQL: SELECT SUM(IIF(timestamp = '2016-05-02 7:50:28', 1, 0)) / SUM(IIF(timestamp = '2016-05-02 7:41:03', 1, 0)) AS num FROM events AS T1 INNER JOIN app_events AS T2 ON T1.event_id = T2.event_id WHERE T2.is_active = '1'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: How many devices are of the brand vivo?
Evidence: brand vivo refers to phone_brand = 'vivo';
SQL: SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'vivo'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: How many more devices are there of the brand vivo than of the brand LG?
Evidence: how many more = SUBTRACT(SUM(IF(phone_brand = 'vivo',1,0)), SUM(IF(phone_brand = 'LG',1,0))); brand vivo refers to phone_brand = 'vivo'; brand LG refers to phone_brand = 'LG';
SQL: SELECT SUM(IIF(phone_brand = 'vivo', 1, 0)) - SUM(IIF(phone_brand = 'LG', 1, 0)) AS num FROM phone_brand_device_model2
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: What is the ID of the device used by the youngest user?
Evidence: ID of the device refers to device_id; youngest user refers to MIN(age);
SQL: SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age )
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Among the female users of the devices, how many of them are over 30?
Evidence: female refers to gender = 'F'; over 30 refers to age > 30;
SQL: SELECT COUNT(device_id) FROM gender_age WHERE age > 30 AND gender = 'F'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Is the oldest device user male or female?
Evidence: MAX(Age) AND gender = 'M' means that the oldest device user is male; MAX(Age) AND gender = 'F' means that the oldest device user is female;
SQL: SELECT gender FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age )
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: What is the age of the youngest female device user?
Evidence: youngest refers to MIN(age); female refers to gender = 'F';
SQL: SELECT MIN(age) FROM gender_age WHERE gender = 'F'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Among all the users who use a vivo device, what is the age of the youngest user?
Evidence: vivo device refers to phone_brand = 'vivo'; youngest refers to MIN(age);
SQL: SELECT T1.age 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' ORDER BY T1.age LIMIT 1
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Please list the app IDs of all the users in the Securities category.
SQL: 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 = 'Securities'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: For the device with an event occurring on 2016/5/1 at 0:55:25, what is the gender of its user?
Evidence: on 2016/5/1 at 0:55:25 refers to timestamp = '2016-05-01 00:55:25';
SQL: SELECT T1.gender FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE T2.timestamp = '2016-05-01 00:55:25'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Among the devices with an event occurring in 2016, how many of them are owned by a user in the M23-26 user group?
Evidence: in 2016 refers to year(timestamp) = 2016; M23-26 user group refers to `group` = 'M23-26';
SQL: SELECT COUNT(T1.device_id) FROM gender_age AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.device_id WHERE STRFTIME('%Y', T2.timestamp) = '2016' AND T1.`group` = 'M23-26'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: What is the brand of the device used by the most users in the M23-26 user group?
Evidence: brand of the device refers to phone_brand; M23-26 user group refers to `group` = 'M23-26';
SQL: SELECT T.phone_brand FROM ( SELECT T2.phone_brand, 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 T1.`group` = 'M23-26' GROUP BY T2.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Please list the location coordinates of all the Galaxy Note 2 devices when an event happened.
Evidence: location coordinates = longitude, latitude; Galaxy Note 2 refers to device_model = 'Galaxy Note 2';
SQL: SELECT T1.longitude, T1.latitude FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T2.device_model = 'Galaxy Note 2'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Please list all the models of the devices used by a female user.
Evidence: models of the devices refers to device_model; female refers to gender = 'F';
SQL: SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F'
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: What are the categories that app user ID7324884708820020000 belongs to?
Evidence: app user ID refers to app_id; app_id = 7324884708820020000;
SQL: 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 = 7324884708820020000
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: Among the app users who were not active when event no.2 happened, how many of them belong to the category Property Industry 1.0?
Evidence: not active refers to is_active = 0; event no. refers to event_id; event_id = 2;
SQL: SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.is_active = 0 AND T1.category = 'Property Industry 1.0' AND T3.event_id = 2
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: How many categories in total do the app users who were not active when event no.2 happened belong to?
Evidence: not active refers to is_active = 0; event no. refers to event_id; event_id = 2;
SQL: SELECT COUNT(*) FROM ( SELECT COUNT(DISTINCT T1.category) AS result FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id INNER JOIN app_events AS T3 ON T2.app_id = T3.app_id WHERE T3.event_id = 2 AND T3.is_active = 0 GROUP BY T1.category ) T
Database: talkingdata
Tables: app_all, app_events, app_events_relevant, app_labels, events, events_relevant, gender_age, gender_age_test, gender_age_train, label_categories, phone_brand_device_model2, sample_submission
Columns (table index, column name): -1, *, 0, app_id, 1, event_id, 1, app_id, 1, is_installed, 1, is_active, 2, event_id, 2, app_id, 2, is_installed, 2, is_active, 3, app_id, 3, label_id, 4, event_id, 4, device_id, 4, timestamp, 4, longitude, 4, latitude, 5, event_id, 5, device_id, 5, timestamp, 5, longitude, 5, latitude, 6, device_id, 6, gender, 6, age, 6, group, 7, device_id, 8, device_id, 8, gender, 8, age, 8, group, 9, label_id, 9, category, 10, device_id, 10, phone_brand, 10, device_model, 11, device_id, 11, F23-, 11, F24-26, 11, F27-28, 11, F29-32, 11, F33-42, 11, F43+, 11, M22-, 11, M23-26, 11, M27-28, 11, M29-31, 11, M32-38, 11, M39+
Question: What is the device model used by the most female users over 30?
Evidence: female users refers to gender = 'F'; most female users refers to MAX(COUNT(gender = 'F')); over 30 refers to age > 30;
SQL: SELECT T.device_model FROM ( SELECT T2.device_model, COUNT(T2.device_model) 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 > 30 AND T1.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 1