db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
university
Please list the IDs of the universities with the top 3 female students percentage in 2011.
in 2011 refers to year 2011; top 3 female students percentage refers to MAX(pct_female_students) LIMIT 3; ID of the university refers to university_id
SELECT university_id FROM university_year WHERE year = 2011 ORDER BY pct_female_students DESC LIMIT 3
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
List down the image IDs for menu located at Manhattan Hotel.
located at Manhattan Hotel refers to location = 'Manhattan Hotel';
SELECT T1.image_id FROM MenuPage AS T1 INNER JOIN Menu AS T2 ON T2.id = T1.menu_id WHERE T2.location = 'Manhattan Hotel'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Among the universities with over 20000 students in 2011, how many of them have an international students percentage of over 25% in the same year?
in 2011 refers to year 2011; with over 20000 students refers to num_students > 20000; international students percentage of over 25% refers to pct_international_students > 25;
SELECT COUNT(*) FROM university_year WHERE year = 2011 AND pct_international_students > 25 AND num_students > 20000
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
What is the occasion for menu with ID 12463?
FALSE;
SELECT occasion FROM Menu WHERE id = 12463
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Please list the IDs of the universities with a student staff ratio of over 15 in 2011.
in 2011 refers to year 2011; student staff ratio of over 15 refers to student_staff_ratio > 15; ID of the university refers to university_id
SELECT university_id FROM university_year WHERE year = 2011 AND student_staff_ratio > 15
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Is "c02c9a3b-6881-7080-e040-e00a180631aa" the uuid for menu called "The Biltmore"?
if 'c02c9a3b-6881-7080-e040-e00a180631aa' can be found in uuid, it means the 'c02c9a3b-6881-7080-e040-e00a180631aa' is the uuid for the menu called The Biltmore; if 'c02c9a3b-6881-7080-e040-e00a180631aa' can not be found in uuid, it means the 'c02c9a3b-6881-7080-e040-e00a180631aa' is not the uuid for the menu called The Biltmore; The Biltmore is a name of menu;
SELECT CASE WHEN T2.uuid = 'c02c9a3b-6881-7080-e040-e00a180631aa' THEN 'yes' ELSE 'no' END AS yn FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id WHERE T1.name = 'The Biltmore' AND T2.uuid = 'c02c9a3b-6881-7080-e040-e00a180631aa'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What is the ID of the university with the most students in 2011?
in 2011 refers to year 2011; with the most students refers to MAX(num_students); ID of the university refers to university_id
SELECT university_id FROM university_year WHERE year = 2011 ORDER BY num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
List down the menu page IDs for menu sponsored by Occidental & Oriental?
menu page IDs refers to MenuPage.id; sponsored by Occidental & Oriental refers to sponsor = 'Occidental & Oriental';
SELECT T2.id FROM MenuPage AS T1 INNER JOIN Menu AS T2 ON T2.id = T1.menu_id WHERE T2.sponsor = 'Occidental & Oriental'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
How many students were there in university ID 1 in 2011?
in 2011 refers to year 2011;
SELECT num_students FROM university_year WHERE year = 2011 AND university_id = 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Name the university and country which had the highest number of international students in 2015.
highest number of international students refers to MAX(DIVIDE(MULTIPLY(num_students, pct_international_students), 100)); in 2015 refers to year = 2015; name of university refers to university_name;
SELECT T1.university_name, T3.country_name 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 = 2015 ORDER BY T2.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
How many of the books authored by Al Gore have less than 400 pages?
"AI Gore" is the author_name; have less than 400 pages refers to num_pages < 400
SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Al Gore' AND T1.num_pages < 400
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
What is the page count for menu with page ID of 130?
page ID of 130 refers MenuPage.id = 130;
SELECT T1.page_count FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id WHERE T2.id = 130
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Calculate the average score per university under Alumni criteria in 2008.
under Alumni criteria refers to criteria_name = 'Alumni'; in 2008 refers to year = 2008; average score refers to DIVIDE(SUM(score), COUNT(university_id))
SELECT AVG(T2.score) FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id WHERE T1.criteria_name = 'Alumni' AND T2.year = 2008
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Provide the ranking criteria and scores in 2005 that were received by Harvard University.
Harvard University refers to university_name = 'Harvard University'; in 2005 refers to year = 2005; ranking criteria refers to criteria_name;
SELECT T1.criteria_name, 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 = 'Harvard University' AND T2.year = 2005
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
State the full height and width for menu called "El Fuerte Del Palmar".
width refers to full_width; El Fuerte Del Palmar is a name of menu;
SELECT T1.full_height, T1.full_width FROM MenuPage AS T1 INNER JOIN Menu AS T2 ON T2.id = T1.menu_id WHERE T2.name = 'El Fuerte Del Palmar'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
How many percent of universities got a score above 80 under International criteria in 2016? Among them, name the university which got the highest score.
got a score above 80 refers to score > 80; under International criteria refers to criteria_name = 'International'; in 2016 refers to year = 2016; highest score refers to MAX(score)
SELECT CAST(SUM(CASE WHEN T2.score > 80 THEN 1 ELSE 0 END) AS REAL) / COUNT(*), ( SELECT T3.university_name 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 T1.criteria_name = 'International' AND T2.year = 2016 AND T2.score > 80 ORDER BY T2.score DESC LIMIT 1 ) AS max 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 T1.criteria_name = 'International' AND T2.year = 2016
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
List down the page numbers for menu with dishes on the right upper corner.
on the right upper corner refers to xpos > 0.75 AND ypos < 0.25;
SELECT T2.page_number FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id INNER JOIN MenuItem AS T3 ON T2.id = T3.menu_page_id WHERE T3.xpos > 0.75 AND T3.ypos < 0.25
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Provide the ranking system name for the "Quality of Education Rank" criteria.
the "Quality of Education Rank" criteria refers to criteria_name = 'Quality of Education Rank'; ranking system refers to system_name
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 = 'Quality of Education Rank'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
In 2011, which university got the lowest score in teaching criteria?
in 2011 refers to year 2011; got the lowest score refers to MIN(score), teaching criteria refers to criteria_name = 'Teaching'
SELECT T3.university_name 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 T1.criteria_name = 'Teaching' AND T2.year = 2011 ORDER BY T2.score ASC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
State the name of menu with the longest full height.
longest full height refers to MAX(full_height);
SELECT T2.name FROM MenuPage AS T1 INNER JOIN Menu AS T2 ON T2.id = T1.menu_id ORDER BY T1.full_height DESC LIMIT 1
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
List the ranking criteria under the Shanghai Ranking system.
Shanghai Ranking system refers to system_name = 'Shanghai Ranking'; ranking criteria refers to criteria_name
SELECT T2.criteria_name FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Shanghai Ranking'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Provide the universities which got the highest scores.
got the highest scores refers to MAX(SUM(score))
SELECT T1.university_name FROM university AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.university_id GROUP BY T1.university_name ORDER BY SUM(T2.score) DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
How much is the price of menu with image ID 4000009194?
FALSE;
SELECT T3.price FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id INNER JOIN MenuItem AS T3 ON T2.id = T3.menu_page_id WHERE T2.image_id = 4000009194
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Calculate the number of female students at Arizona State University in 2014.
female students refers to DIVIDE(MULTIPLY(pct_female_students, num_students), 100); at Arizona State University refers to university_name = 'Arizona State University'; in 2014 refers to year = 2014
SELECT 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 WHERE T1.university_name = 'Arizona State University' AND T2.year = 2014
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
How many international students attended Harvard University in 2012?
Harvard University refers to university_name = 'Harvard University'; international students refers to DIVIDE(MULTIPLY(num_students, pct_international_students), 100); in 2012 refers to year = 2012
SELECT CAST(T2.num_students * T2.pct_international_students AS REAL) / 100 FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id WHERE T1.university_name = 'Harvard University' AND T2.year = 2012
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Which product has the highest total amount of quantity sold? Calculate its overall total price.
highest total amount of quantity refers to MAX(Quantity); overall total price = SUM(MULTIPLY(Quantity, Price));
SELECT T1.Name, SUM(T2.Quantity * T1.Price) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T1.Name ORDER BY SUM(T2.Quantity) DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Which country has the University of São Paulo?
the University of São Paulo refers to university_name = 'University of São Paulo'; which country refers to country_name;
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T1.university_name = 'University of São Paulo'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Provide the number of staff at the University of Auckland in 2015.
University of Auckland refers to university_name = 'University of Auckland'; in 2015 refers to year = 2015; number of staff refers to DIVIDE(num_students, student_staff_ratio)
SELECT CAST(SUM(T1.num_students) AS REAL) / SUM(T1.student_staff_ratio) FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'University of Auckland' AND T1.year = 2015
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
Calculate the total price of books ordered by customer named Lucas Wyldbore.
total price refers to Sum(price); full name is composed of first name, last name
SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
How many employees sold over 20,000 quantities of "Touring-2000 Blue, 50"?
over 20,000 quantities refers to Quantity > 20000; 'Touring-2000 Blue, 50' is name of product;
SELECT COUNT(*) FROM ( SELECT SUM(Quantity) FROM Sales WHERE ProductID IN ( SELECT ProductID FROM Products WHERE Name = 'Touring-2000 Blue, 50' ) GROUP BY Quantity, SalesPersonID HAVING SUM(Quantity) > 20000 )
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
List the universities in Denmark.
in Denmark refers to country_name = 'Denmark'; name of university refers to university_name;
SELECT T1.university_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Denmark'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
What is the name of the publisher that published the most books?
name of publisher refers to publisher_name; publisher published the most number of books refers to Max(Count(book_id))
SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T2.publisher_id) DESC LIMIT 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
university
Provide the number of students at Yale University in 2016.
number of students refers to num_students; Yale University refers to university_name = 'Yale University'; in 2016 refers to year = 2016
SELECT T1.num_students FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Yale University' AND T1.year = 2016
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
List the customer's ID and last name of the customer that purchased a product with a quantity greater than 90% of the average quantity of all listed products.
quantity greater than 90% of the average quantity = Quantity > MULTIPLY(AVG(Quantity), 0.9);
SELECT T2.CustomerID, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Quantity > ( SELECT AVG(Quantity) FROM Sales ) * 0.9
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many universities got less than 50 scores under ranking criteria ID 6 in 2011?
in 2011 refers to year 2011; less than 50 scores refers to score < 50;
SELECT COUNT(*) FROM university_ranking_year WHERE ranking_criteria_id = 6 AND year = 2011 AND score < 50
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Among the products that have price ranges from 100 to 150, what is the customer ID and sales ID of the product with a quantity lower than 25?
price ranges from 100 to 150 refers to Price BETWEEN 100 AND 150; quantity lower than 25 refers to Quantity < 25;
SELECT T2.CustomerID, T2.SalesID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price BETWEEN 100 AND 150 AND T2.Quantity < 25
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many universities had above 30% of international students in 2013?
had above 30% of international students refers to pct_international_students > 30; in 2013 refers to year = 2013
SELECT COUNT(*) FROM university_year WHERE pct_international_students > 30 AND year = 2013
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
What is the ID of the Publications Rank criteria?
Publications Rank criteria refers to criteria_name = 'Publications Rank';
SELECT id FROM ranking_criteria WHERE criteria_name = 'Publications Rank'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
What is the price and quantity of the product named Seat Tube?
null
SELECT DISTINCT T2.Price, T1.Quantity FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Seat Tube'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Provide the ranking system ID of the Center for World University Rankings.
the Center for World University Rankings refers to system_name = 'Center for World University Rankings';
SELECT id FROM ranking_system WHERE system_name = 'Center for World University Rankings'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
In sales ID between 30 and 40, who is the customer that bought a total quantity of 403?
who refers to FirstName, LastName;
SELECT T2.FirstName, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Quantity = 403 AND T1.SalesID BETWEEN 30 AND 40
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
What is the country ID of the University of Tokyo?
University of Tokyo refers to university_name = 'University of Tokyo';
SELECT country_id FROM university WHERE university_name = 'University of Tokyo'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
In customers with the first name of Erica, how many of them bought a quantity below 200?
quantity below 200 refers to quantity < 200;
SELECT COUNT(T1.ProductID) FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Erica' AND T1.Quantity < 200
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many universities had over 30000 students in 2011?
in 2011 refers to year 2011; had over 30000 students refers to num_students > 30000;
SELECT COUNT(*) FROM university_year WHERE year = 2011 AND num_students > 30000
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
In sales with a quantity of 60, how many of them have a price not greater than 500?
null
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity = 60 AND T1.Price <= 500
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
What is the difference in overall student enrollment and international student enrollment at the Harvard university from 2011 to 2012?
Harvard University refers to university_name = 'Harvard University'; difference in overall student enrollment and international student refers to SUBTRACT(SUM(num_students), SUM(DIVIDE(MULTIPLY(pct_international_students, num_students), 100))); from 2011 to 2012 refers to year BETWEEN 2011 AND 2012
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 T2.university_name = 'Harvard University' AND T1.year BETWEEN 2011 AND 2012
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Among products bought by Kathryn Ashe, what is the name of the product with the highest quantity?
highest quantity refers to MAX(Quantity);
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Kathryn' AND T3.LastName = 'Ashe' ORDER BY T2.Quantity DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
What are the top three universities with the most international students?
most international students refers to MAX(SUM(DIVIDE(MULTIPLE(pct_international_students, num_students), 100))); name of university refers to university_name;
SELECT DISTINCT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id GROUP BY T2.university_name ORDER BY SUM(T1.num_students * T1.pct_international_students / 100) DESC LIMIT 3
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
List the sales ID of the product with a quantity of 590 and named "External Lock Washer 7".
External Lock Washer 7' is name of product;
SELECT T1.SalesID FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'External Lock Washer 7' AND T1.Quantity = 590
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many students at the university earned a score of 90 in 2011?
in 2011 refers to year 2011; earned a score of 90 refers to score = 90;
SELECT COUNT(*) FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T2.score = 90 AND T1.year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
How many criteria are associated with ranking system Center for World University Rankings?
ranking system Center for World University Rankings refers to system_name = 'Center for World University Rankings';
SELECT COUNT(T2.criteria_name) FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Center for World University Rankings'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
What is the price and name of the product bought by Erica Xu?
null
SELECT T3.Price, T3.Name FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID WHERE T2.FirstName = 'Erica' AND T2.LastName = 'Xu'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Which universities have more than 100,000 students in 2011?
in 2011 refers to year 2011; more than 100,000 students refers to num_students > 100000; which university refers to university_name;
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 AND T1.num_students > 100000
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Give the product ID and name of the product with the highest prices among the quantity ranges from 400 to 500.
highest prices refers to MAX(Price); quantity ranges from 400 to 500 refers to Quantity BETWEEN 400 AND 500;
SELECT T1.ProductID, T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity BETWEEN 400 AND 500 ORDER BY T1.Price DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
In Argentina, how many universities are there?
In Argentina refers to country_name = 'Argentina';
SELECT COUNT(*) FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Argentina'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Among the sales ID ranges from 1 to 200, what is the percentage of the products with a price ranging from 200 to 300?
sales ID ranges from 1 to 200 refers to SalesID between 1 and 200; percentage = MULTIPLY(DIVIDE(SUM(Price between 200 and 300), COUNT(Price)), 1.0);
SELECT CAST(SUM(IIF(T2.Price BETWEEN 200 AND 300, 1, 0)) AS REAL) * 100 / COUNT(T2.Price) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SalesID BETWEEN 1 AND 200
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Name the most famous university in Argentina.
in Argentina refers to country_name = 'Argentina';  most famous refers to MAX(SUM(score))
SELECT T1.university_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 T3.country_name = 'Argentina' GROUP BY T1.university_name ORDER BY SUM(T2.score) DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How many types of "HL Touring Frames" are there?
types of HL Touring Frames refers to Name like '%HL Touring Frame%';
SELECT COUNT(ProductID) FROM Products WHERE Name LIKE '%HL Touring Frame%'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
What is the name of the ranking system for Teaching criteria?
Teaching criteria refers to criteria_name = 'Teaching'; name of the ranking system refers to system_name
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 = 'Teaching'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
How many books by William Shakespeare were published by Penguin Classics?
"William Shakespeare" is the author_name; "Penguin Classics" is the publisher_name
SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'William Shakespeare' AND T4.publisher_name = 'Penguin Classics'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
How many customers are named Madison?
null
SELECT COUNT(CustomerID) FROM Customers WHERE FirstName = 'Madison'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
In which nation is Harvard University located?
Harvard University refers to university_name = 'Harvard University'; nation refers to country_name
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T1.university_name = 'Harvard University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
What is the full name of the customer who purchased the highest amount of total price in a single purchase?
full name of the customer = FirstName, MiddleInitial, LastName; highest amount of total price refers to MAX(MULTIPLY(Quantity, Price));
SELECT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID GROUP BY T1.SalesID, T1.Quantity, T3.Price, FirstName, MiddleInitial, LastName ORDER BY T1.Quantity * T3.Price DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many female students were there at Stanford University in 2011?
in 2011 refers to year 2011; female students refers to DIVIDE(MULTIPLY(pct_female_students, num_students), 100); Stanford University refers to university_name = 'Stanford University';
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 = 'Stanford University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
What is the percentage of Harvard university's international students in 2011?
Harvard university's refers to university_name = 'Harvard University'; in 2011 refers to year = 2011; percentage of Harvard university's international students refers to pct_international_students
SELECT T1.pct_international_students FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 AND T2.university_name = 'Harvard University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Among customers named Kate, who has the highest quantity?
highest quantity refers to MAX(Quantity);
SELECT T2.FirstName, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Kate' ORDER BY T1.Quantity DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Indicate the university's name with the highest ranking score in Teaching.
university's name refers to university_name; highest ranking score refers to MAX(score); in Teaching refers to criteria_name = 'Teaching'
SELECT T1.university_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 T3.criteria_name = 'Teaching' ORDER BY T2.score DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
What is the name of the most expensive product?
most expensive product refers to MAX(Price);
SELECT Name FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products )
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Name the university that had the most students in 2011.
in 2011 refers to year = 2011; had the most students refers to MAX(num_students); name of university refers to university_name;
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 ORDER BY T1.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Among the products with product ID lower than 15, how many of them costs 10 and below?
product ID lower than 15 refers to ProductID < 15; costs 10 and below refers to Price; Price < = 10;
SELECT COUNT(ProductID) FROM Products WHERE ProductID < 15 AND Price <= 10
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Which university had the highest reputation in 2012?
had the highest reputation refers to MAX(score), in 2012 refers to year = 2012; which university refers to university_name;
SELECT T2.university_name FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2012 ORDER BY T1.score DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How many "Mountain-500 Black 42" were sold in total?
Mountain-500 Black 42' is name of product; sold in total = SUM(Quantity);
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain-500 Black, 42'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Provide the ID of the university with the highest percentage of female students in 2012.
in 2012 refers to year = 2012; highest percentage of female students  refers to MAX(pct_female_students); ID of the university refers to university_id
SELECT university_id FROM university_year WHERE year = 2012 ORDER BY pct_female_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
List the author's and publisher's name of the book published on July 10, 1997.
author's name refers to author_name; publisher's name refers to publisher_name; book published on July 10, 1997 refers to publication_date LIKE '1997-07-10'
SELECT T3.author_name, T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T1.publication_date = '1997-07-10'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
How many free or gift products are there?
free gift refers to Price = 0;
SELECT COUNT(ProductID) FROM Products WHERE Price = 0
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many institutions with over 50,000 students in 2011 had a percentage of oversea students of more than 10%?
institutions with over 50,000 students refers to num_students > 50000; in 2011 refers to year = 2011; percentage of oversea students of more than 10% refers to pct_international_students > 10;
SELECT COUNT(*) FROM university_year WHERE year = 2011 AND num_students > 50000 AND pct_international_students > 10
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How many customers share the most common last name?
most common last name refers to MAX(COUNT(LastName));
SELECT COUNT(CustomerID) FROM Customers GROUP BY LastName ORDER BY COUNT(LastName) DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
What is the university ID with the most students in 2011?
most students refers to MAX(num_students), in 2011 refers to year = 2011
SELECT university_id FROM university_year WHERE year = 2011 ORDER BY num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
What is the name of the sales person who handled the highest number of sales?
name of the sales person = FirstName, MiddleInitial, LastName; highest number of sales refers to MAX(COUNT(SalesID));
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T2.SalesPersonID = T1.EmployeeID GROUP BY T2.SalesPersonID, T1.FirstName, T1.MiddleInitial, T1.LastName ORDER BY COUNT(T2.SalesID) DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
What is the student staff ratio at the university with the greatest student staff ratio of all time?
greatest student staff ratio of all time refers to max(student_staff_ratio)
SELECT MAX(student_staff_ratio) FROM university_year ORDER BY student_staff_ratio DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
What is the total cost of all the "Road-650, Red, 60" products that Abraham E. Bennet sold?
total cost = SUM(MULTIPLY(Quantity, Price)); 'Road-650, Red, 60' is name of product;
SELECT SUM(T2.Quantity * T3.Price) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Abraham' AND T1.MiddleInitial = 'e' AND T1.LastName = 'Bennet' AND T3.Name = 'Road-650 Red, 60'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Among all universities, how many female students were there in 2011?
in 2011 refers to year = 2011; female students refers to SUM(DIVIDE(MULTIPLY(num_students, pct_female_students), 100))
SELECT SUM(CAST(num_students * pct_female_students AS REAL) / 100) FROM university_year WHERE year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
How many students attended universities were there in 2011?
in 2011 refers to year = 2011;
SELECT SUM(num_students) FROM university_year WHERE year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How much is the total amount of sales handled by Heather McBadden?
total amount of sales = SUM(MULTIPLY(Quantity, Price));
SELECT SUM(T2.Quantity * T3.Price) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Heather' AND T1.LastName = 'McBadden'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Among universities that score below 80 in 2015, what is the percentage of international students?
score below 80 refers to score < 80; in 2015 refers to year 2015; percentage of international students refers to DIVIDE(SUM(DIVIDE(MULTIPLY(num_students, pct_international_students), 100)), SUM(num_students))
SELECT SUM(CAST(T1.num_students * T1.pct_international_students AS REAL) / 100) / COUNT(*) * 100 FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T2.score < 80 AND T1.year = 2015
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Provide the country name of universities with the number of students greater than 98% of the average student population of all universities in 2013.
number of students greater than 98% of the average student population of all universities refers to num_students >  MULTPLY(num_students, 0.98); in 2013 refers to year = 2013
SELECT DISTINCT T3.country_name 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 = 2013 AND T2.num_students * 100 > ( SELECT AVG(num_students) FROM university_year ) * 98
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
What is the name of the publisher with publisher ID 22?
name of publisher refers to publisher_name
SELECT publisher_name FROM publisher WHERE publisher_id = 22
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
How many of the employees have the last name "Ringer" ?
null
SELECT COUNT(LastName) FROM Employees WHERE LastName = 'Ringer'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
List the criteria names under the ranking system called Center for World University Ranking.
ranking system called Center for World University Ranking refers to system_name = 'Center for World University Rankings';
SELECT T2.criteria_name FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T1.system_name = 'Center for World University Rankings'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
What is the student population of the university that scored 98 in 2013?
student population refers to num_students; in 2013 refers to year = 2013
SELECT SUM(T1.num_students) FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T2.score = 98 AND T1.year = 2013
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
What is the event sponsored by the Republican House?
sponsored by the Republican House refers to sponsor = 'REPUBLICAN HOUSE';
SELECT event FROM Menu WHERE sponsor = 'REPUBLICAN HOUSE'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Give the score and number of international students in university ID 100 in 2015.
number of international students refers to DIVIDE(MULTIPLY(num_students, pct_international_students), 100); in 2015 refers to year = 2015
SELECT CAST(T1.num_students * T1.pct_international_students AS REAL) / 100, T2.score FROM university_year AS T1 INNER JOIN university_ranking_year AS T2 ON T1.university_id = T2.university_id WHERE T2.year = 2015 AND T1.university_id = 100
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Who is the sponsor of menu with ID 12463?
FALSE;
SELECT sponsor FROM Menu WHERE id = 12463
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
In which country does the most populated university in 2014 located ?
the most populated university refers to max(num_students); in 2014 refers to year = 2014
SELECT T2.country_id FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2014 ORDER BY T1.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Compute the average score of the university located in Brazil.
average score refers to avg(score); located in Brazil refers to country_name = 'Brazil';
SELECT AVG(T2.score) 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 T3.country_name = 'Brazil'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
How many percent of Bluefish dishes are located at the center of the menu page?
percent = MULTIPLY(DIVIDE(SUM(xpos BETWEEN 0.25 AND 0.75 and ypos BETWEEN 0.25 AND 0.75), COUNT(id)), 1.0); Bluefish is a sub name of dish; located at the center of the menu page refers to xpos BETWEEN 0.25 AND 0.75 and ypos BETWEEN 0.25 AND 0.75;
SELECT CAST(SUM(CASE WHEN T2.xpos BETWEEN 0.25 AND 0.75 AND T2.ypos BETWEEN 0.25 AND 0.75 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.id) FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.name LIKE '%BLuefish%'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What is the criteria name of the university ID 32 in 2015?
in 2015 refers to year = 2015
SELECT T1.criteria_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id WHERE T2.university_id = 32 AND T2.year = 2015
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
List the name of universities located in Spain.
name of universities refers to university_name; located in Spain refers to country_name = 'Spain';
SELECT T1.university_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Spain'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Provide the sponsor and event of the menu which includes Cerealine with Milk.
Cerealine with Milk is a name of dish;
SELECT T3.name, T3.event FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Cerealine with Milk'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What is the ranking criteria ID of Brown University in 2014?
Brown University refers to university_name = 'Brown University'; in 2014 refers to year = 2014
SELECT T1.ranking_criteria_id FROM university_ranking_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Brown University' AND T1.year = 2014
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );