input
stringlengths
358
16.1k
output
stringlengths
24
805
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Which ranking system is criteria "Total Shanghai" in? [/INST]
SELECT T1.system_name FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T2.criteria_name = 'Total Shanghai';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: How many female students were there in Pierre and Marie Curie University in 2015? [/INST]
SELECT CAST(T1.num_students * T1.pct_female_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 AND T2.university_name = 'Pierre and Marie Curie University';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: What was the score for University of Florida in "N and S" in 2014? [/INST]
SELECT T2.score FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T3.university_name = 'University of Florida' AND T2.year = 2014 AND T1.criteria_name = 'N and S';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the number of international students of University of Wisconsin-Madison in 2013. [/INST]
SELECT CAST(T1.num_students * T1.pct_international_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2013 AND T2.university_name = 'University of Wisconsin-Madison';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Show the name of the university with the lowest number of students in 2015. [/INST]
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 ORDER BY T1.num_students ASC LIMIT 1;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: How many times more was the number of students of University of Ottawa than Joseph Fourier University in 2013? [/INST]
SELECT CAST(SUM(CASE WHEN T2.university_name = 'University of Ottawa' THEN T1.num_students ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.university_name = 'Joseph Fourier University' THEN T1.num_students ELSE 0 END) FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2013;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average number of criterias among "Times Higher Education World University Ranking","Shanghai Ranking" and "Center for World University Rankings". [/INST]
SELECT (SUM(CASE WHEN T1.system_name = 'Center for World University Rankings' THEN 1 ELSE 0 END) + SUM(CASE WHEN T1.system_name = 'Shanghai Ranking' THEN 1 ELSE 0 END) + SUM(CASE WHEN T1.system_name = 'Times Higher Education World University Ranking' THEN 1 ELSE 0 END)) / 3 FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average number of students of all universities in 2012. [/INST]
SELECT AVG(num_students) FROM university_year WHERE year = 2012;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: What is the score of university ID 68 in 2015? [/INST]
SELECT score FROM university_ranking_year WHERE year = 2015 AND university_id = 68;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Provide the country ID of Cyprus. [/INST]
SELECT id FROM country WHERE country_name = 'Cyprus';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: What is the ID of university with the largest percentage of international students? [/INST]
SELECT university_id FROM university_year ORDER BY pct_international_students DESC LIMIT 1;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Provide the criteria name of the ranking criteria ID 13. [/INST]
SELECT criteria_name FROM ranking_criteria WHERE id = 13;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average score of all universities in 2012? [/INST]
SELECT AVG(score) FROM university_ranking_year WHERE year = 2012;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: In years 2011 to 2013, what is the total number of female students in university ID 40? [/INST]
SELECT SUM(CAST(num_students * pct_female_students AS REAL) / 100) FROM university_year WHERE year BETWEEN 2011 AND 2013 AND university_id = 40;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average score of university ID 79 between year 2013 to 2015. [/INST]
SELECT AVG(score) FROM university_ranking_year WHERE year BETWEEN 2013 AND 2015 AND university_id = 79;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Give the student staff ratio of university ID 35. [/INST]
SELECT student_staff_ratio FROM university_year WHERE university_id = 35;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Provide the score of the most populated university in 2011. [/INST]
SELECT T2.score FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T1.year = 2011 ORDER BY T1.num_students DESC LIMIT 1;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Give the criteria name where Harvard University scored 100. [/INST]
SELECT DISTINCT T3.criteria_name FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN ranking_criteria AS T3 ON T3.id = T2.ranking_criteria_id WHERE T1.university_name = 'Harvard University' AND T2.score = 100;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Provide the university name and ID of the university found in Turkey. [/INST]
SELECT T1.university_name, T1.id FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Turkey';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total number of ranking criteria under the ranking system called Shanghai Ranking? [/INST]
SELECT COUNT(*) FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Shanghai Ranking';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Give the name and score of the university ID 124. [/INST]
SELECT T2.university_name, T1.score FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.id = 124;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: How many female students are there in University of Pennsylvania in 2011? [/INST]
SELECT CAST(T1.num_students * T1.pct_female_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 AND T2.university_name = 'University of Pennsylvania';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: List down all universities that scored below 50. [/INST]
SELECT DISTINCT T2.university_name FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.score < 50;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: How many universities are located in Japan? [/INST]
SELECT COUNT(*) FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Japan';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Provide the name of the university with the highest number of male students. [/INST]
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id ORDER BY T1.num_students * T1.pct_female_students / 100 - T1.num_students DESC LIMIT 1;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: List the countries of universities that scored 70 and below in 2016. [/INST]
SELECT DISTINCT T3.country_name FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T2.score < 70 AND T2.year = 2016;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate number of male students in Emory University in 2011. [/INST]
SELECT CAST((T1.num_students - (T1.num_students * T1.pct_female_students)) AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Emory University' AND T1.year = 2011;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: In which country does Johns Hopkins University located? [/INST]
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T1.university_name = 'Johns Hopkins University';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Give the names of universities with number of students ranges from 400 to 1000. [/INST]
SELECT DISTINCT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.num_students BETWEEN 400 AND 1000;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: In what year does the Brown University score the highest? [/INST]
SELECT T1.year FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Brown University' ORDER BY T1.score DESC LIMIT 1;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average score of Emory University from 2011 to 2016. [/INST]
SELECT AVG(T1.score) FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Emory University' AND T1.year BETWEEN 2011 AND 2016;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Give the name of the university with the most number of students in 2015. [/INST]
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 ORDER BY T1.num_students DESC LIMIT 1;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: What is the location and number of female students in university ID 23 in 2011? [/INST]
SELECT T3.country_name, CAST(T2.num_students * T2.pct_female_students AS REAL) / 100 FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T2.year = 2011 AND T1.id = 23;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: How many universities scored 40 in teaching criteria? [/INST]
SELECT COUNT(*) FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id WHERE T2.score = 40 AND T1.criteria_name = 'Teaching' AND T2.score = 40;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Among the universities in United States of America, what is the percentage of female students in year 2016? [/INST]
SELECT SUM(CAST(T2.pct_female_students * T2.num_students AS REAL) / 100) * 100 / SUM(T2.num_students) FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T3.country_name = 'United States of America' AND T2.year = 2016;
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the difference between the total number of students and the number of international international students in Univeristy of Tokyo from 2011 to 2014. [/INST]
SELECT SUM(T1.num_students) - SUM(CAST(T1.num_students * T1.pct_international_students AS REAL) / 100) FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year BETWEEN 2011 AND 2014 AND T2.university_name = 'University of Tokyo';
[INST] Here is a database schema: country : id [ INTEGER ] primary_key country_name [ TEXT ] ranking_system : id [ INTEGER ] primary_key system_name [ TEXT ] ranking_criteria : id [ INTEGER ] primary_key ranking_system_id [ INTEGER ] ranking_criteria.ranking_system_id = ranking_system.id criteria_name [ TEXT ] university : id [ INTEGER ] primary_key country_id [ INTEGER ] university.country_id = country.id university_name [ TEXT ] university_ranking_year : university_id [ INTEGER ] university_ranking_year.university_id = university.id ranking_criteria_id [ INTEGER ] university_ranking_year.ranking_criteria_id = ranking_criteria.id year [ INTEGER ] score [ INTEGER ] university_year : university_id [ INTEGER ] university_year.university_id = university.id year [ INTEGER ] num_students [ INTEGER ] student_staff_ratio [ REAL ] pct_international_students [ INTEGER ] pct_female_students [ INTEGER ] Please write me a SQL statement that answers the following question: List the names of universities with a score less than 28% of the average score of all universities in 2015. [/INST]
SELECT T2.university_name FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 AND T1.score * 100 < ( SELECT AVG(score) * 28 FROM university_ranking_year WHERE year = 2015 );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many units of item no.9 were sold in store no.1 on 2012/1/1? [/INST]
SELECT units FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 AND item_nbr = 9;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many units of item no.9 were sold in store no.1 in total in January, 2012? [/INST]
SELECT SUM(units) FROM sales_in_weather WHERE SUBSTR(`date`, 6, 2) = '01' AND SUBSTR(`date`, 1, 4) = '2012' AND item_nbr = 9 AND store_nbr = 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the ID of the item that sold the best on 2012/1/1 in store no.1? [/INST]
SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What was the temperature range of station no.1 on 2012/1/1? [/INST]
SELECT tmax - tmin AS temrange FROM weather WHERE station_nbr = 1 AND `date` = '2012-01-01';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Please list the dates on which the temperature of station no.2 was above the 30-year normal. [/INST]
SELECT `date` FROM weather WHERE station_nbr = 2 AND depart > 0;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: On which day was the weather more windy in station no.1, 2012/1/1 or 2012/1/2? [/INST]
SELECT CASE WHEN (SUM(CASE WHEN `date` = '2012-01-01' THEN avgspeed ELSE 0 END) - SUM(CASE WHEN `date` = '2012-01-02' THEN avgspeed ELSE 0 END)) > 0 THEN '2012-01-01' ELSE '2012-01-02' END FROM weather WHERE station_nbr = 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the total number of units of item no.5 sold in store no.3 in 2012 on days when the temperature was below the 30-year normal? [/INST]
SELECT SUM(CASE WHEN T3.depart < 0 THEN units ELSE 0 END) AS sum FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.item_nbr = 5;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many units of item no.5 were sold in store no.3 on the day in 2012 when the max temperature was the highest? [/INST]
SELECT T1.units FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.item_nbr = 5 ORDER BY tmax DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What was the dew point on the day the most units of item no.5 were sold in store no.3 in 2012? [/INST]
SELECT dewpoint FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.item_nbr = 5 ORDER BY units DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: On how many days with the max temperature over 90 did the sale of item no.5 in store no.3 exceed 100? [/INST]
SELECT SUM(CASE WHEN units > 100 THEN 1 ELSE 0 END) AS count FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.item_nbr = 5 AND tmax > 90;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many units of item no.5 were sold in store no.3 on the day the temperature range was the biggest? [/INST]
SELECT t2.units FROM relation AS T1 INNER JOIN sales_in_weather AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T1.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T2.item_nbr = 5 ORDER BY t3.tmax - t3.tmin DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Among the days on which over 100 units of item no.5 were sold in store no.3, on which date was the temperature range the biggest? [/INST]
SELECT T2.`date` FROM relation AS T1 INNER JOIN sales_in_weather AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T1.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T2.item_nbr = 5 AND T2.units > 100 ORDER BY tmax - tmin DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many units of item no.5 were sold in store no.3 in total on days with a total precipitation of over 0.05? [/INST]
SELECT SUM(CASE WHEN T3.preciptotal > 0.05 THEN units ELSE 0 END) AS sum FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T1.item_nbr = 5;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Please list the dates on which the sale of item no.5 in store no.3 exceeded 100 and the average wind speed exceeded 10. [/INST]
SELECT T1.`date` FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T1.item_nbr = 5 AND T1.units > 100 AND T3.avgspeed > 10;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the total units of products sold on the day with the highest max temperature in store no.3 in 2012? [/INST]
SELECT SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T2.store_nbr = 3 AND T1.`date` LIKE '%2012%' GROUP BY T3.tmax ORDER BY T3.tmax DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many more units of item no.16 were sold on the day with the highest max temperature in 2012 in store no.5 than in store no.10? [/INST]
SELECT ( SELECT SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.item_nbr = 16 AND T1.`date` LIKE '%2012%' AND T1.store_nbr = 5 GROUP BY tmax ORDER BY T3.tmax DESC LIMIT 1 ) - ( SELECT SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.item_nbr = 16 AND T1.`date` LIKE '%2012%' AND T1.store_nbr = 6 GROUP BY tmax ORDER BY T3.tmax DESC LIMIT 1 );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the ID of the item that sold the best on the day with the highest max temperature in store no.3 in 2012? [/INST]
SELECT T1.item_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.`date` LIKE '%2012%' AND tmax = ( SELECT MAX(tmax) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.`date` LIKE '%2012%' ) GROUP BY T1.item_nbr ORDER BY SUM(units) DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: On the day with the highest max temperature in 2012, how many items in store no.3 had no sales? [/INST]
SELECT COUNT(DISTINCT T1.item_nbr) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr AND T1.store_nbr = 3 AND SUBSTR(T1.`date`, 1, 4) = '2012' AND T1.units = 0 GROUP BY T3.tmax ORDER BY T3.tmax DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many units of item no.5 were sold in store no.3 on average on the days when the max temperature exceeded 90? [/INST]
SELECT CAST(SUM(T1.units) AS REAL) / COUNT(T1.`date`) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.item_nbr = 5 AND T3.tmax > 90;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the percentage of the units of item no.5 sold among all units of items sold in store no.3 on the day with the highest max temperature in 2012? [/INST]
SELECT CAST(SUM(CASE WHEN T1.item_nbr = 5 THEN units * 1 ELSE 0 END) AS REAL) * 100 / SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.`date` LIKE '%2012%' AND T3.tmax = ( SELECT MAX(T3.tmax) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T1.store_nbr = 3 AND T1.`date` LIKE '%2012%' );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Give the id of the bestsellers of store no.1 on 2012/1/1. [/INST]
SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many no.9 items from store no.11 were sold on 2012/12/7? [/INST]
SELECT units FROM sales_in_weather WHERE `date` = '2012-12-07' AND store_nbr = 11 AND item_nbr = 9;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Give the average temperature of station no.20 on 2014/10/17. [/INST]
SELECT tavg FROM weather WHERE `date` = '2014-10-17' AND station_nbr = 20;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Tell the resultant wind speed of station no.9 on 2014/1/15. [/INST]
SELECT resultspeed FROM weather WHERE `date` = '2014-01-15' AND station_nbr = 9;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Give the id of the weather station with most stores. [/INST]
SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(station_nbr) DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Which weather station does store no.20 belong to? [/INST]
SELECT station_nbr FROM relation WHERE store_nbr = 20;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Tell the temperature range of the home weather station of store no.7 on 2014/4/28. [/INST]
SELECT T1.tmax - T1.tmin AS temprange FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 7 AND T1.`date` = '2014-04-28';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: For the weather station which recorded the highest temperature above the 30-year normal, how many stores does it have? [/INST]
SELECT store_nbr FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY depart DESC LIMIT 1 );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: For the home weather station of store no.15, what was the dew point on 2012/2/18? [/INST]
SELECT T1.dewpoint FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 15 AND T1.`date` = '2012-02-18';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Tell the wet-bulb temperature of the weather station which contained store no.6 on 2012/2/15. [/INST]
SELECT T1.wetbulb FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 14 AND T1.`date` = '2012-02-15';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Give the number of stores which opened on the weather station that recorded the fastest average wind speed. [/INST]
SELECT COUNT(T.store_nbr) FROM ( SELECT DISTINCT store_nbr FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY avgspeed DESC LIMIT 1 ) ) T;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: State the max temperature of the weather station which has the no.21 store on 2012/11/9. [/INST]
SELECT tmax FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 21 AND T1.`date` = '2012-11-09';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Provide the sunrise time recorded by the home weather station of store no.30 on 2014/2/21. [/INST]
SELECT T1.sunrise FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2014-02-21' AND store_nbr = 30;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: State the number of stores that belongs to the weather station which recorded the deepest snowfall. [/INST]
SELECT T2.store_nbr FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr ORDER BY snowfall DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Provide the code summarization for the weather recorded by the weather station which contained the no.2 store on 2013/2/12. [/INST]
SELECT T1.codesum FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2013-02-12' AND T2.store_nbr = 2;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Show the sea level status recorded by the weather station of store no.19 on 2013/2/24. [/INST]
SELECT T1.sealevel FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2013-02-24' AND T2.store_nbr = 19;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many inches of total precipitation was recorded by the weather station of store no.2 on 2012/12/25? [/INST]
SELECT T1.preciptotal FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2012-12-25' AND T2.store_nbr = 2;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Give the station pressure status recorded by the weather station which contained no.12 store on 2012/5/15. [/INST]
SELECT T1.stnpressure FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.`date` = '2012-05-15' AND T2.store_nbr = 12;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What percentage was the total unit sales of store no.10 to the total sales of its weather station on 2014/10/31? [/INST]
SELECT CAST(SUM(CASE WHEN T2.store_nbr = 10 THEN units * 1 ELSE 0 END) AS REAL) * 100 / SUM(units) FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr WHERE T1.`date` = '2014-10-31';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: For the weather station has store no.9, what was the increased percentage of the average temperature from 2012/2/2 to 2012/2/3? [/INST]
SELECT CAST((SUM(CASE WHEN T1.`date` = '2012-02-03' THEN T1.tavg * 1 ELSE 0 END) - SUM(CASE WHEN T1.`date` = '2012-02-02' THEN T1.tavg * 1 ELSE 0 END)) AS REAL) * 100 / SUM(CASE WHEN T1.`date` = '2012-02-02' THEN T1.tavg * 1 ELSE 0 END) FROM weather AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr WHERE T2.store_nbr = 9;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the item number of the product with the highest number of units sold in store number 1 on 1/1/2012? [/INST]
SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many stores are in weather station 12? [/INST]
SELECT SUM(store_nbr) FROM relation WHERE station_nbr = 12;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many items weren't sold in store 2 on 1/1/2012? [/INST]
SELECT COUNT(item_nbr) FROM sales_in_weather WHERE store_nbr = 2 AND units = 0 AND `date` = '2012-01-01';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Between 1/1/2012 to 12/31/2014, which date recorded the hottest temperature in weather station 1? [/INST]
SELECT `date` FROM weather WHERE station_nbr = 1 AND CAST(SUBSTR(`date`, 1, 4) AS int) BETWEEN 2012 AND 2014 ORDER BY tmax DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Which weather station has the highest number of stores? [/INST]
SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(store_nbr) DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: In March 2014, which weather stations recorded the highest number of days whose temperature is below the 30-year normal? [/INST]
SELECT station_nbr FROM weather WHERE SUBSTR(`date`, 1, 4) = '2014' AND SUBSTR(`date`, 6, 2) = '03' AND depart < 0 GROUP BY station_nbr HAVING COUNT(DISTINCT `date`) = ( SELECT COUNT(DISTINCT `date`) FROM weather WHERE SUBSTR(`date`, 1, 4) = '2014' AND SUBSTR(`date`, 6, 2) = '03' AND depart < 0 GROUP BY station_nbr ORDER BY COUNT(`date`) DESC LIMIT 1 );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Which weather station does the store that sold the highest quantity of item 9 belongs to? [/INST]
SELECT station_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr WHERE T1.item_nbr = 9 GROUP BY T2.station_nbr ORDER BY SUM(T1.units) DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many stores belong to the most windy station? [/INST]
SELECT COUNT(store_nbr) FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY avgspeed DESC LIMIT 1 );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Among the stores in weather station 14 in February 2014, which store had sold no less than 300 quantities for item number 44 in a single day? [/INST]
SELECT T1.store_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr WHERE T2.station_nbr = 14 AND T1.`date` LIKE '%2014-02%' AND T1.item_nbr = 44 AND units >= 300;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the most purchased products during the rainy days in June 2013 in weather station 9? [/INST]
SELECT T1.item_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN weather AS T3 ON T2.station_nbr = T3.station_nbr WHERE T3.station_nbr = 9 AND T1.`date` LIKE '%2013-06%' AND codesum = 'RA' ORDER BY T1.units DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Which station sold the highest quantity of item number 5 overall? [/INST]
SELECT T2.station_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr WHERE T1.item_nbr = 5 GROUP BY T2.station_nbr ORDER BY SUM(T1.units) DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the earliest sunrise recorded in the stations with no more than 1 store in February 2012? [/INST]
SELECT T1.station_nbr FROM relation AS T1 INNER JOIN weather AS T2 ON T1.station_nbr = T2.station_nbr WHERE sunrise IS NOT NULL AND T2.`date` LIKE '%2012-02%' AND T1.station_nbr IN ( SELECT station_nbr FROM relation GROUP BY station_nbr HAVING COUNT(store_nbr) = 1 ) ORDER BY sunrise LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: In weather station 17, which store sold the highest quantity of item 45 in October 2012? [/INST]
SELECT T1.store_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr WHERE T1.item_nbr = 45 AND T2.station_nbr = 17 AND T1.`date` LIKE '%2012-10%' GROUP BY T1.store_nbr ORDER BY SUM(T1.units) DESC LIMIT 1;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What are the items sold by the store during the day whose station recorded the thickest snowfall? [/INST]
SELECT T1.item_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr INNER JOIN ( SELECT station_nbr, `date` FROM weather ORDER BY snowfall DESC LIMIT 1 ) AS T3 ON T2.station_nbr = T3.station_nbr;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What are the top 3 stations that have sold the highest quantities for an item in a single day? [/INST]
SELECT T2.station_nbr FROM sales_in_weather AS T1 INNER JOIN relation AS T2 ON T1.store_nbr = T2.store_nbr ORDER BY T1.units DESC LIMIT 3;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many stores belong to the station with the highest recorded heat of all time? [/INST]
SELECT COUNT(T2.store_nbr) FROM ( SELECT station_nbr FROM weather ORDER BY heat DESC LIMIT 1 ) AS T1 INNER JOIN relation AS T2 ON T1.station_nbr = T2.station_nbr;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: On February 8, 2014, what is the minimum temperature in the station where store 29 belongs? [/INST]
SELECT tmin FROM relation AS T1 INNER JOIN weather AS T2 ON T1.station_nbr = T2.station_nbr WHERE T1.store_nbr = 29 AND T2.`date` = '2014-02-08';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Among the stations with 3 stores, how many stations have a station pressure of no more than 30 on February 18, 2014? [/INST]
SELECT COUNT(station_nbr) FROM weather WHERE `date` = '2014-02-18' AND stnpressure < 30 AND station_nbr IN ( SELECT station_nbr FROM relation GROUP BY station_nbr HAVING COUNT(store_nbr) = 3 );
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Which station has the highest number of stores? Calculate the said station's average maximum temperature in February 2012. [/INST]
SELECT CAST(SUM(T2.tmax) AS REAL) / 29 FROM ( SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(store_nbr) DESC LIMIT 1 ) AS T1 INNER JOIN weather AS T2 ON T1.station_nbr = T2.station_nbr WHERE SUBSTR(T2.`date`, 1, 7) = '2012-02';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: Between the stores under weather station 12, what is the percentage of item 5 sold in store 10 in 2014? [/INST]
SELECT CAST(SUM(CASE WHEN T2.store_nbr = 10 THEN units * 1 ELSE 0 END) AS REAL) * 100 / SUM(units) FROM relation AS T1 INNER JOIN sales_in_weather AS T2 ON T1.store_nbr = T2.store_nbr WHERE station_nbr = 12 AND item_nbr = 5 AND T2.`date` LIKE '%2014%';
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: What is the maximum average speed? [/INST]
SELECT MAX(avgspeed) FROM weather;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many days did the show fell more than 5 inches? [/INST]
SELECT COUNT(DISTINCT `date`) FROM weather WHERE snowfall > 5;
[INST] Here is a database schema: sales_in_weather : date [ DATE ] store_nbr [ INTEGER ] item_nbr [ INTEGER ] units [ INTEGER ] weather : station_nbr [ INTEGER ] date [ DATE ] tmax [ INTEGER ] tmin [ INTEGER ] tavg [ INTEGER ] depart [ INTEGER ] dewpoint [ INTEGER ] wetbulb [ INTEGER ] heat [ INTEGER ] cool [ INTEGER ] sunrise [ TEXT ] sunset [ TEXT ] codesum [ TEXT ] snowfall [ REAL ] preciptotal [ REAL ] stnpressure [ REAL ] sealevel [ REAL ] resultspeed [ REAL ] resultdir [ INTEGER ] avgspeed [ REAL ] relation : store_nbr [ INTEGER ] primary_key relation.store_nbr = sales_in_weather.store_nbr station_nbr [ INTEGER ] relation.station_nbr = weather.station_nbr Please write me a SQL statement that answers the following question: How many days did the sun rise before 5 AM? [/INST]
SELECT COUNT(DISTINCT `date`) AS days FROM weather WHERE sunrise < time('05:00:00');