input
stringlengths 236
16.9k
| output
stringlengths 19
805
|
---|---|
-- 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 ] |
-- -- Which ranking system is criteria "Total Shanghai" in?
| 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'; |
-- 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 ] |
-- -- How many female students were there in Pierre and Marie Curie University in 2015?
| 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'; |
-- 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 ] |
-- -- What was the score for University of Florida in "N and S" in 2014?
| 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'; |
-- 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 ] |
-- -- Calculate the number of international students of University of Wisconsin-Madison in 2013.
| 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'; |
-- 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 ] |
-- -- Show the name of the university with the lowest number of students in 2015.
| 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; |
-- 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 ] |
-- -- How many times more was the number of students of University of Ottawa than Joseph Fourier University in 2013?
| 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; |
-- 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 ] |
-- -- Calculate the average number of criterias among "Times Higher Education World University Ranking","Shanghai Ranking" and "Center for World University Rankings".
| 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; |
-- 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 ] |
-- -- Calculate the average number of students of all universities in 2012.
| SELECT AVG(num_students) FROM university_year WHERE year = 2012; |
-- 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 ] |
-- -- What is the score of university ID 68 in 2015?
| SELECT score FROM university_ranking_year WHERE year = 2015 AND university_id = 68; |
-- 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 ] |
-- -- Provide the country ID of Cyprus.
| SELECT id FROM country WHERE country_name = 'Cyprus'; |
-- 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 ] |
-- -- What is the ID of university with the largest percentage of international students?
| SELECT university_id FROM university_year ORDER BY pct_international_students DESC LIMIT 1; |
-- 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 ] |
-- -- Provide the criteria name of the ranking criteria ID 13.
| SELECT criteria_name FROM ranking_criteria WHERE id = 13; |
-- 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 ] |
-- -- What is the average score of all universities in 2012?
| SELECT AVG(score) FROM university_ranking_year WHERE year = 2012; |
-- 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 ] |
-- -- In years 2011 to 2013, what is the total number of female students in university ID 40?
| SELECT SUM(CAST(num_students * pct_female_students AS REAL) / 100) FROM university_year WHERE year BETWEEN 2011 AND 2013 AND university_id = 40; |
-- 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 ] |
-- -- Calculate the average score of university ID 79 between year 2013 to 2015.
| SELECT AVG(score) FROM university_ranking_year WHERE year BETWEEN 2013 AND 2015 AND university_id = 79; |
-- 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 ] |
-- -- Give the student staff ratio of university ID 35.
| SELECT student_staff_ratio FROM university_year WHERE university_id = 35; |
-- 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 ] |
-- -- Provide the score of the most populated university in 2011.
| 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; |
-- 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 ] |
-- -- Give the criteria name where Harvard University scored 100.
| 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; |
-- 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 ] |
-- -- Provide the university name and ID of the university found in Turkey.
| 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'; |
-- 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 ] |
-- -- What is the total number of ranking criteria under the ranking system called Shanghai Ranking?
| 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'; |
-- 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 ] |
-- -- Give the name and score of the university ID 124.
| 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; |
-- 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 ] |
-- -- How many female students are there in University of Pennsylvania in 2011?
| 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'; |
-- 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 ] |
-- -- List down all universities that scored below 50.
| 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; |
-- 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 ] |
-- -- How many universities are located in Japan?
| SELECT COUNT(*) FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Japan'; |
-- 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 ] |
-- -- Provide the name of the university with the highest number of male students.
| 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; |
-- 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 ] |
-- -- List the countries of universities that scored 70 and below in 2016.
| 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; |
-- 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 ] |
-- -- Calculate number of male students in Emory University in 2011.
| 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; |
-- 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 ] |
-- -- In which country does Johns Hopkins University located?
| 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'; |
-- 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 ] |
-- -- Give the names of universities with number of students ranges from 400 to 1000.
| 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; |
-- 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 ] |
-- -- In what year does the Brown University score the highest?
| 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; |
-- 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 ] |
-- -- Calculate the average score of Emory University from 2011 to 2016.
| 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; |
-- 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 ] |
-- -- Give the name of the university with the most number of students in 2015.
| 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; |
-- 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 ] |
-- -- What is the location and number of female students in university ID 23 in 2011?
| 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; |
-- 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 ] |
-- -- How many universities scored 40 in teaching criteria?
| 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; |
-- 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 ] |
-- -- Among the universities in United States of America, what is the percentage of female students in year 2016?
| 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; |
-- 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 ] |
-- -- Calculate the difference between the total number of students and the number of international international students in Univeristy of Tokyo from 2011 to 2014.
| 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'; |
-- 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 ] |
-- -- List the names of universities with a score less than 28% of the average score of all universities in 2015.
| 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 ); |
-- 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 |
-- -- How many units of item no.9 were sold in store no.1 on 2012/1/1?
| SELECT units FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 AND item_nbr = 9; |
-- 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 |
-- -- How many units of item no.9 were sold in store no.1 in total in January, 2012?
| 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; |
-- 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 |
-- -- What is the ID of the item that sold the best on 2012/1/1 in store no.1?
| SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1; |
-- 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 |
-- -- What was the temperature range of station no.1 on 2012/1/1?
| SELECT tmax - tmin AS temrange FROM weather WHERE station_nbr = 1 AND `date` = '2012-01-01'; |
-- 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 list the dates on which the temperature of station no.2 was above the 30-year normal.
| SELECT `date` FROM weather WHERE station_nbr = 2 AND depart > 0; |
-- 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 |
-- -- On which day was the weather more windy in station no.1, 2012/1/1 or 2012/1/2?
| 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; |
-- 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 |
-- -- 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?
| 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; |
-- 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 |
-- -- 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?
| 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; |
-- 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 |
-- -- What was the dew point on the day the most units of item no.5 were sold in store no.3 in 2012?
| 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; |
-- 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 |
-- -- On how many days with the max temperature over 90 did the sale of item no.5 in store no.3 exceed 100?
| 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; |
-- 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 |
-- -- How many units of item no.5 were sold in store no.3 on the day the temperature range was the biggest?
| 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; |
-- 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 |
-- -- 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?
| 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; |
-- 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 |
-- -- 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?
| 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; |
-- 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 list the dates on which the sale of item no.5 in store no.3 exceeded 100 and the average wind speed exceeded 10.
| 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; |
-- 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 |
-- -- What is the total units of products sold on the day with the highest max temperature in store no.3 in 2012?
| 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; |
-- 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 |
-- -- 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?
| 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 ); |
-- 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 |
-- -- 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?
| 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; |
-- 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 |
-- -- On the day with the highest max temperature in 2012, how many items in store no.3 had no sales?
| 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; |
-- 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 |
-- -- How many units of item no.5 were sold in store no.3 on average on the days when the max temperature exceeded 90?
| 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; |
-- 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 |
-- -- 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?
| 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%' ); |
-- 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 |
-- -- Give the id of the bestsellers of store no.1 on 2012/1/1.
| SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1; |
-- 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 |
-- -- How many no.9 items from store no.11 were sold on 2012/12/7?
| SELECT units FROM sales_in_weather WHERE `date` = '2012-12-07' AND store_nbr = 11 AND item_nbr = 9; |
-- 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 |
-- -- Give the average temperature of station no.20 on 2014/10/17.
| SELECT tavg FROM weather WHERE `date` = '2014-10-17' AND station_nbr = 20; |
-- 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 |
-- -- Tell the resultant wind speed of station no.9 on 2014/1/15.
| SELECT resultspeed FROM weather WHERE `date` = '2014-01-15' AND station_nbr = 9; |
-- 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 |
-- -- Give the id of the weather station with most stores.
| SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(station_nbr) DESC LIMIT 1; |
-- 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 |
-- -- Which weather station does store no.20 belong to?
| SELECT station_nbr FROM relation WHERE store_nbr = 20; |
-- 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 |
-- -- Tell the temperature range of the home weather station of store no.7 on 2014/4/28.
| 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'; |
-- 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 |
-- -- For the weather station which recorded the highest temperature above the 30-year normal, how many stores does it have?
| SELECT store_nbr FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY depart DESC LIMIT 1 ); |
-- 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 |
-- -- For the home weather station of store no.15, what was the dew point on 2012/2/18?
| 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'; |
-- 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 |
-- -- Tell the wet-bulb temperature of the weather station which contained store no.6 on 2012/2/15.
| 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'; |
-- 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 |
-- -- Give the number of stores which opened on the weather station that recorded the fastest average wind speed.
| 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; |
-- 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 |
-- -- State the max temperature of the weather station which has the no.21 store on 2012/11/9.
| 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'; |
-- 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 |
-- -- Provide the sunrise time recorded by the home weather station of store no.30 on 2014/2/21.
| 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; |
-- 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 |
-- -- State the number of stores that belongs to the weather station which recorded the deepest snowfall.
| 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; |
-- 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 |
-- -- Provide the code summarization for the weather recorded by the weather station which contained the no.2 store on 2013/2/12.
| 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; |
-- 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 |
-- -- Show the sea level status recorded by the weather station of store no.19 on 2013/2/24.
| 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; |
-- 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 |
-- -- How many inches of total precipitation was recorded by the weather station of store no.2 on 2012/12/25?
| 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; |
-- 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 |
-- -- Give the station pressure status recorded by the weather station which contained no.12 store on 2012/5/15.
| 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; |
-- 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 |
-- -- What percentage was the total unit sales of store no.10 to the total sales of its weather station on 2014/10/31?
| 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'; |
-- 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 |
-- -- 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?
| 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; |
-- 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 |
-- -- What is the item number of the product with the highest number of units sold in store number 1 on 1/1/2012?
| SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1; |
-- 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 |
-- -- How many stores are in weather station 12?
| SELECT SUM(store_nbr) FROM relation WHERE station_nbr = 12; |
-- 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 |
-- -- How many items weren't sold in store 2 on 1/1/2012?
| SELECT COUNT(item_nbr) FROM sales_in_weather WHERE store_nbr = 2 AND units = 0 AND `date` = '2012-01-01'; |
-- 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 |
-- -- Between 1/1/2012 to 12/31/2014, which date recorded the hottest temperature in weather station 1?
| 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; |
-- 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 |
-- -- Which weather station has the highest number of stores?
| SELECT station_nbr FROM relation GROUP BY station_nbr ORDER BY COUNT(store_nbr) DESC LIMIT 1; |
-- 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 |
-- -- In March 2014, which weather stations recorded the highest number of days whose temperature is below the 30-year normal?
| 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 ); |
-- 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 |
-- -- Which weather station does the store that sold the highest quantity of item 9 belongs to?
| 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; |
-- 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 |
-- -- How many stores belong to the most windy station?
| SELECT COUNT(store_nbr) FROM relation WHERE station_nbr = ( SELECT station_nbr FROM weather ORDER BY avgspeed DESC LIMIT 1 ); |
-- 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 |
-- -- 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?
| 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; |
-- 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 |
-- -- What is the most purchased products during the rainy days in June 2013 in weather station 9?
| 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; |
-- 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 |
-- -- Which station sold the highest quantity of item number 5 overall?
| 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; |
-- 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 |
-- -- What is the earliest sunrise recorded in the stations with no more than 1 store in February 2012?
| 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; |
-- 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 |
-- -- In weather station 17, which store sold the highest quantity of item 45 in October 2012?
| 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; |
-- 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 |
-- -- What are the items sold by the store during the day whose station recorded the thickest snowfall?
| 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; |
-- 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 |
-- -- What are the top 3 stations that have sold the highest quantities for an item in a single day?
| 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; |
-- 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 |
-- -- How many stores belong to the station with the highest recorded heat of all time?
| 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; |
-- 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 |
-- -- On February 8, 2014, what is the minimum temperature in the station where store 29 belongs?
| 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'; |
-- 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 |
-- -- Among the stations with 3 stores, how many stations have a station pressure of no more than 30 on February 18, 2014?
| 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 ); |
-- 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 |
-- -- Which station has the highest number of stores? Calculate the said station's average maximum temperature in February 2012.
| 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'; |
-- 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 |
-- -- Between the stores under weather station 12, what is the percentage of item 5 sold in store 10 in 2014?
| 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%'; |
-- 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 |
-- -- What is the maximum average speed?
| SELECT MAX(avgspeed) FROM weather; |
-- 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 |
-- -- How many days did the show fell more than 5 inches?
| SELECT COUNT(DISTINCT `date`) FROM weather WHERE snowfall > 5; |
-- 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 |
-- -- How many days did the sun rise before 5 AM?
| SELECT COUNT(DISTINCT `date`) AS days FROM weather WHERE sunrise < time('05:00:00'); |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.