input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many professors teaches no more than two high-level or harder undergraduate courses? [/INST]
SELECT COUNT(*) FROM ( SELECT COUNT(T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400' GROUP BY T2.p_id HAVING COUNT(DISTINCT T1.course_id) <= 2 );
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Between the faculty employee professors, how many teaches high-level or harder undergraduate courses? Indicate each of the professors unique identifying number. [/INST]
SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_eme' AND T1.professor = 1 AND T3.courseLevel = 'Level_400';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: What is the position in the faculty of the professor who teaches the highest number of courses? [/INST]
SELECT T1.hasPosition FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: What year in the program do the students with more than 2 advisors are in? [/INST]
SELECT T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.student = 1 GROUP BY T2.p_id HAVING COUNT(T2.p_id) > 2;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many professors teaches basic or medium undergraduate courses? [/INST]
SELECT COUNT(*) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_300';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Among the students being advised by advisors, which students' year in the program do the advisors advise the majority of? [/INST]
SELECT T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.student = 1 GROUP BY T2.yearsInProgram ORDER BY COUNT(T1.p_id_dummy) DESC LIMIT 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: How many students that are undergoing the pre-phase of qualification have advisors? [/INST]
SELECT COUNT(T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.inPhase = 'Pre_Quals' AND T2.student = 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: What is the average number of professional or master/undergraduate courses being taught by each professor? [/INST]
SELECT CAST(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500';
[INST] Here is a database schema: taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many courses were taught by more than 4 people? [/INST]
SELECT COUNT(*) FROM ( SELECT COUNT(course_id) FROM taughtBy GROUP BY course_id HAVING COUNT(course_id) > 4 );
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] Please write me a SQL statement that answers the following question: What is the total of professional courses available at the university? List out all the course id. [/INST]
SELECT COUNT(course_id) FROM course WHERE courseLevel = 'Level_500';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] Please write me a SQL statement that answers the following question: What is the sum of year 1 and year 2 students? [/INST]
SELECT COUNT(*) FROM person WHERE yearsInProgram = 'Year_1' OR yearsInProgram = 'Year_2';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many courses were taught by a professor who is currently the member of faculty? [/INST]
SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition <> 0;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which professor taught the most courses and what is the position of this person in the university? [/INST]
SELECT T1.p_id, T1.hasPosition FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which courses were taught by a professor who is not a faculty member? [/INST]
SELECT DISTINCT T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition = 0;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which member of the faculty are teaching the most courses and what is his/her general course level? [/INST]
SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id GROUP BY T1.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the device id of the oldest user? [/INST]
SELECT device_id FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age );
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: How many female users over the age of 50 are there? [/INST]
SELECT COUNT(gender) FROM gender_age WHERE age > 50 AND gender = 'F';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] Please write me a SQL statement that answers the following question: How many active users were there in the event id 2? [/INST]
SELECT COUNT(is_active) FROM app_events WHERE event_id = 2 AND is_active = 1;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the gender of the youngest user? [/INST]
SELECT gender FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age );
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: What is the name of the category which most users belong to? [/INST]
SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the model of the oldest user's device? [/INST]
SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id ORDER BY T2.age DESC LIMIT 1;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: How many users are there in the Home Decoration category? [/INST]
SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Home Decoration';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] 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 ] Please write me a SQL statement that answers the following question: How many male users are active in the events held on 5/1/2016? [/INST]
SELECT COUNT(T3.gender) FROM app_events AS T1 INNER JOIN events_relevant AS T2 ON T2.event_id = T1.event_id INNER JOIN gender_age AS T3 ON T3.device_id = T2.device_id WHERE T1.is_active = 1 AND T3.gender = 'M' AND T2.timestamp LIKE '2016-05-01%';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many female users use ZenFone 5 devices? [/INST]
SELECT COUNT(T1.gender) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.gender = 'F' AND T2.device_model = 'ZenFone 5';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] 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 ] Please write me a SQL statement that answers the following question: What is the age of the oldest active user that participated in the event held on 5/6/2016 at coordinates 121, 31? [/INST]
SELECT T3.age FROM app_events AS T1 INNER JOIN events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN gender_age AS T3 ON T2.device_id = T3.device_id WHERE T1.is_active = 1 AND T2.longitude = 121 AND T2.latitude = 31 AND SUBSTR(T2.timestamp, 1, 10) = '2016-05-06' ORDER BY T3.age DESC LIMIT 1;
[INST] Here is a database schema: 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_relevant : event_id [ INTEGER ] primary_key device_id [ INTEGER ] events_relevant.device_id = gender_age.device_id timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: What are the categories of the top 2 oldest events? [/INST]
SELECT T4.category FROM events_relevant AS T1 INNER JOIN app_events_relevant AS T2 ON T1.event_id = T2.event_id INNER JOIN app_labels AS T3 ON T3.app_id = T2.app_id INNER JOIN label_categories AS T4 ON T3.label_id = T4.label_id ORDER BY T1.timestamp LIMIT 2;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the gender of the majority of Vivo phone users? [/INST]
SELECT T.gender FROM ( SELECT T2.gender, COUNT(T2.gender) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'vivo' GROUP BY T2.gender ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Which category has the highest number of users? [/INST]
SELECT T.category FROM ( SELECT T2.category, COUNT(T1.app_id) AS num FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id GROUP BY T1.app_id, T2.category ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: How many users belong to the MOBA category? [/INST]
SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'MOBA';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the percentage of female OPPO users against the male OPPO users? [/INST]
SELECT SUM(IIF(T2.gender = 'F', 1, 0)) * 100 / COUNT(T2.device_id) AS perFemale , SUM(IIF(T2.gender = 'M', 1, 0)) * 100 / COUNT(T2.device_id) AS perMale FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'OPPO';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] Please write me a SQL statement that answers the following question: List the app users IDs and installed status for the event ID of 844. [/INST]
SELECT app_id , IIF(is_installed = 1, 'YES', 'NO') AS status FROM app_events WHERE event_id = 844;
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many users used Vivo Xplay3S model? [/INST]
SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE device_model = 'Xplay3S' AND phone_brand = 'vivo';
[INST] Here is a database schema: label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: What are the labels' IDs of online shopping and online malls categories? [/INST]
SELECT label_id FROM label_categories WHERE category IN ('online shopping', 'online malls');
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Describe the phone brands and models of the users who participated in events on 5th May, 2016 at the coordinates of (112,44). [/INST]
SELECT DISTINCT T2.phone_brand, T2.device_model FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T2.device_id = T1.device_id WHERE T1.timestamp LIKE '2016-05-05%' AND T1.longitude = 112 AND T1.latitude = 44;
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] Please write me a SQL statement that answers the following question: Provide the app users IDs and time for the event ID of 82. [/INST]
SELECT T1.app_id, T2.timestamp FROM app_events AS T1 INNER JOIN events AS T2 ON T2.event_id = T1.event_id WHERE T2.event_id = 82;
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] 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 ] Please write me a SQL statement that answers the following question: Describe the device user gender and age of the event ID of 15251. [/INST]
SELECT T1.gender, T1.age FROM gender_age AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.event_id = 15251;
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Provide the phone brands and models of the users who were at the coordinates of (80,44). [/INST]
SELECT DISTINCT T1.phone_brand, T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T2.longitude = 80 AND T2.latitude = 44;
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] 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 label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: List the included categories in the event ID of 155. [/INST]
SELECT DISTINCT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id INNER JOIN app_events AS T3 ON T3.app_id = T2.app_id WHERE T3.event_id = 155;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among HTC Butterfly phone users, list any five devices' IDs used by females. [/INST]
SELECT T2.device_id FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Butterfly' AND T2.gender = 'F' AND T1.phone_brand = 'HTC' LIMIT 5;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: How many app IDs were included under science fiction category? [/INST]
SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'science fiction';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What are the ages and genders of the LG L70 users? [/INST]
SELECT T2.age, T2.gender FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG' AND T1.device_model = 'L70';
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the percentage of the app user IDs under Industry tag category. [/INST]
SELECT SUM(IIF(T1.category = 'Industry tag', 1, 0)) * 100 / COUNT(T2.app_id) AS per FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among the LG brand users, calculate the percentage of the Nexus 5 model user. What is the ratio of male and female users of it? [/INST]
SELECT SUM(IIF(T1.device_model = 'Nexus 5', 1, 0)) * 100 / COUNT(T1.device_id) AS per , SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'M', 1, 0)) / SUM(IIF(T1.device_model = 'Nexus 5' AND T2.gender = 'F', 1, 0)) AS r FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'LG';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] Please write me a SQL statement that answers the following question: How many users of the app were not active when event no.2 happened? [/INST]
SELECT COUNT(event_id) FROM app_events WHERE event_id = 2 AND is_active = 0;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: How many device users are male? [/INST]
SELECT COUNT(device_id) FROM gender_age WHERE gender = 'M';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the age of the oldest device user? [/INST]
SELECT MAX(age) FROM gender_age;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: Among the female users of the devices, how many of them are under 30? [/INST]
SELECT COUNT(device_id) FROM gender_age WHERE age < 30 AND gender = 'F';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among the users who use a Galaxy Note 2, how many of them are female? [/INST]
SELECT COUNT(T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T2.gender = 'F' AND T1.device_model = 'Galaxy Note 2';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Please list the ages of all the users who use a Galaxy Note 2. [/INST]
SELECT T2.age FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T2.device_id = T1.device_id WHERE T1.device_model = 'Galaxy Note 2';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the device model of the device used by the oldest user? [/INST]
SELECT device_model FROM phone_brand_device_model2 WHERE device_id IN ( SELECT device_id FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age ) );
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: How many app users belong to the category of Securities? [/INST]
SELECT COUNT(T1.app_id) FROM app_labels AS T1 INNER JOIN label_categories AS T2 ON T2.label_id = T1.label_id WHERE T2.category = 'Securities';
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: To which categories does app user no.1977658975649780000 belong? [/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 = 1977658975649780000;
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] 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 label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Please list the categories of the app users who are not active when event no.2 happened. [/INST]
SELECT DISTINCT T1.category 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;
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] Please write me a SQL statement that answers the following question: Please list the location coordinates of all the devices with an inactive app user when event no.2 happened. [/INST]
SELECT DISTINCT T2.longitude, T2.latitude FROM app_events AS T1 INNER JOIN events AS T2 ON T2.event_id = T1.event_id WHERE T2.event_id = 2 AND T1.is_active = 0;
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] Please write me a SQL statement that answers the following question: Among all the times event no.2 happened when the app user was not active, when was the earliest time this situation happened? [/INST]
SELECT T2.timestamp FROM app_events AS T1 INNER JOIN events AS T2 ON T2.event_id = T1.event_id WHERE T1.is_active = 0 AND T2.event_id = 2 ORDER BY T2.timestamp LIMIT 1;
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Please list the IDs of the events happened on all the vivo devices. [/INST]
SELECT T2.event_id FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'vivo';
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among the devices with event no.2 happening, how many of them are vivo devices? [/INST]
SELECT COUNT(T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T2.device_id = T1.device_id WHERE T1.phone_brand = 'vivo' AND T2.event_id = 2;
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Please list the time when event no.2 happened on a vivo device. [/INST]
SELECT T1.timestamp FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE T2.phone_brand = 'vivo' AND T1.event_id = '2';
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many events in total have happened on all the vivo devices in the year 2016? [/INST]
SELECT COUNT(T1.event_id) FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE STRFTIME('%Y', T1.timestamp) = '2016' AND T2.phone_brand = 'vivo';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among the users who uses a vivo device, how many of them are female and under 30? [/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.gender = 'F' AND T2.phone_brand = 'vivo' AND T1.age < 30;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: What is the category that the most app users belong to? [/INST]
SELECT T.category FROM ( SELECT T1.category, COUNT(T2.app_id) AS num FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id GROUP BY T1.label_id ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the brand of the device used by the youngest female user? [/INST]
SELECT phone_brand FROM phone_brand_device_model2 WHERE device_id IN ( SELECT * FROM ( SELECT device_id FROM gender_age WHERE gender = 'F' ORDER BY age LIMIT 1 ) AS T );
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among all the devices with event no.2 happening, what is the percentage of the device being a vivo phone? [/INST]
SELECT SUM(IIF(T2.phone_brand = 'vivo', 1, 0)) / COUNT(T1.device_id) AS per FROM events AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.event_id = T2.device_id WHERE T1.event_id = '2';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the average age of all the vivo device users? [/INST]
SELECT AVG(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';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the age of the oldest male user of the app? [/INST]
SELECT MAX(age) FROM gender_age WHERE gender = 'M';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] Please write me a SQL statement that answers the following question: How many users installed the app but are not active? [/INST]
SELECT COUNT(app_id) FROM app_events WHERE is_installed = 1 AND is_active = 0;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the age of the youngest female user of the app? [/INST]
SELECT MIN(age) FROM gender_age WHERE gender = 'F';
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many models does the VIVO phone brand released? [/INST]
SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'vivo';
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: List at least 15 phone models released under the OPPO brand. [/INST]
SELECT device_model FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO' LIMIT 15;
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: List 5 device models that users use to install the app and are active in using the app. [/INST]
SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.event_id INNER JOIN app_events AS T3 ON T2.event_id = T3.event_id WHERE T3.is_active = 1 AND T3.is_installed = 1 LIMIT 5;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: How many users belong to "Financial Information" 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 = 'Financial Information';
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: How many users belong to "game-Art Style" 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 = 'game-Art Style';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Provide the total number of the male users that use OPPO as their phone brand. [/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.phone_brand = 'OPPO' AND T1.gender = 'M';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the brand of the youngest user's device? [/INST]
SELECT device_model FROM phone_brand_device_model2 WHERE device_id IN ( SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age ) );
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: List at least 3 categories with the lowest number of users. [/INST]
SELECT T1.category FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id ORDER BY T2.label_id LIMIT 3;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many male users use the Galaxy Ace Plus model? [/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 Ace Plus' AND T1.gender = 'M';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: List at least 5 device models that are commonly used by female users. [/INST]
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.gender = 'F' GROUP BY T2.device_model ) AS T ORDER BY T.num DESC LIMIT 5;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the ratio in percentage between the average number of app users belonging to "80s Japanese comic" and "90s Japanese comic". [/INST]
SELECT SUM(IIF(T1.category = '80s Japanese comic', 1, 0)) / COUNT(T1.label_id) AS J8 , SUM(IIF(T1.category = '90s Japanese comic', 1, 0)) / COUNT(T1.label_id) AS J9 FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T1.label_id = T2.label_id;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among the female users that uses OPPO as their phone brand, what is the percentage of them of the user that uses R815T model to install the app? [/INST]
SELECT SUM(IIF(T1.phone_brand = 'OPPO', 1, 0)) / SUM(IIF(T1.device_id = 'R815T', 1, 0)) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T2.gender = 'F';
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: What is the phone brand of the device model "坚果手机"? [/INST]
SELECT phone_brand FROM phone_brand_device_model2 WHERE device_model = '坚果手机';
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Give the number of device models for "中兴" phone brand. [/INST]
SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE device_model = '中兴';
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] Please write me a SQL statement that answers the following question: Give the time stamp for event No.887711. [/INST]
SELECT timestamp FROM events WHERE event_id = '887711';
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: For the event which happened at 23:55:16 on 2016/5/7, in the location coordinate(113, 28), on what device did it happen? Give the name of the device model. [/INST]
SELECT T1.device_model FROM phone_brand_device_model2 AS T1 INNER JOIN events AS T2 ON T1.device_id = T2.event_id WHERE T2.longitude = '113' AND T2.latitude = '28' AND T2.timestamp = '2016-05-07 23:55:16';
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Give the number of "game-Fishing" apps. [/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 = 'game-Fishing';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Give the number of female users of "E派" brand devices. [/INST]
SELECT COUNT(T2.device_id) FROM gender_age AS T1 INNER JOIN phone_brand_device_model2 AS T2 ON T1.device_id = T2.device_id WHERE T1.gender = 'F' AND T2.phone_brand = 'E派';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many male users of the "Galaxy S5" device model? [/INST]
SELECT COUNT(T1.device_id) FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id WHERE T1.device_model = 'Galaxy S5' AND T2.gender = 'M';
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Which category does the app id No.894384172610331000 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 = '894384172610331000';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] Please write me a SQL statement that answers the following 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? [/INST]
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';
[INST] Here is a database schema: app_events : event_id [ INTEGER ] app_events.event_id = events.event_id app_id [ INTEGER ] is_installed [ bool ] is_active [ bool ] events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] Please write me a SQL statement that answers the following 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? [/INST]
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';
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many devices are of the brand vivo? [/INST]
SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'vivo';
[INST] Here is a database schema: phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: How many more devices are there of the brand vivo than of the brand LG? [/INST]
SELECT SUM(IIF(phone_brand = 'vivo', 1, 0)) - SUM(IIF(phone_brand = 'LG', 1, 0)) AS num FROM phone_brand_device_model2;
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the ID of the device used by the youngest user? [/INST]
SELECT device_id FROM gender_age WHERE age = ( SELECT MIN(age) FROM gender_age );
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: Among the female users of the devices, how many of them are over 30? [/INST]
SELECT COUNT(device_id) FROM gender_age WHERE age > 30 AND gender = 'F';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: Is the oldest device user male or female? [/INST]
SELECT gender FROM gender_age WHERE age = ( SELECT MAX(age) FROM gender_age );
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] Please write me a SQL statement that answers the following question: What is the age of the youngest female device user? [/INST]
SELECT MIN(age) FROM gender_age WHERE gender = 'F';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Among all the users who use a vivo device, what is the age of the youngest user? [/INST]
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;
[INST] Here is a database schema: app_labels : app_id [ INTEGER ] app_labels.app_id = app_all.app_id label_id [ INTEGER ] app_labels.label_id = label_categories.label_id label_categories : label_id [ INTEGER ] primary_key category [ TEXT ] Please write me a SQL statement that answers the following question: Please list the app IDs of all the users in the Securities 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 = 'Securities';
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] 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 ] Please write me a SQL statement that answers the following question: For the device with an event occurring on 2016/5/1 at 0:55:25, what is the gender of its user? [/INST]
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';
[INST] Here is a database schema: events : event_id [ INTEGER ] primary_key device_id [ INTEGER ] timestamp [ DATETIME ] longitude [ REAL ] latitude [ REAL ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Please list the location coordinates of all the Galaxy Note 2 devices when an event happened. [/INST]
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';
[INST] Here is a database schema: gender_age : device_id [ INTEGER ] primary_key gender_age.device_id = phone_brand_device_model2.device_id gender [ TEXT ] age [ INTEGER ] group [ TEXT ] phone_brand_device_model2 : device_id [ INTEGER ] phone_brand [ TEXT ] device_model [ TEXT ] Please write me a SQL statement that answers the following question: Please list all the models of the devices used by a female user. [/INST]
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';