db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
app_store
What is the rating for "Garden Coloring Book"? List all of its reviews.
Golfshot Plus: Golf GPS refers to App = 'Golfshot Plus: Golf GPS'; review refers to Translated_Review;
SELECT T1.Rating, T2.Translated_Review FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Garden Coloring Book'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
Describe the specific description and case locations under IUCR 142.
specific description refers to secondary_description; location refers to latitude, longitude; IUCR 142 refers to iucr_no = 142
SELECT T1.secondary_description, T2.latitude, T2.longitude FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no WHERE T2.iucr_no = 142
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
List the company names of customers from the city with the most customers.
most customers refers to max(count(Relationship))
SELECT CompanyName FROM `Customer and Suppliers by City` WHERE CITY = ( SELECT City FROM `Customer and Suppliers by City` GROUP BY City ORDER BY COUNT(Relationship) DESC LIMIT 1 )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
Indicate the ISBN13 of all the books that have less than 140 pages and more than 135.
ISBN13 refers to isbn13; less than 140 pages and more than 135 refers to num_pages > 135 AND num_pages < 140;
SELECT isbn13 FROM book WHERE num_pages < 140 AND num_pages > 135
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, );
app_store
How many negative comments are there in all the apps with 100,000,000+ installs?
negative comment refers to Sentiment = 'Negative'; Installs = '100,000,000+';
SELECT COUNT(T2.Sentiment) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Installs = '100,000,000+' AND T2.Sentiment = 'Negative'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
List down the titles and descriptions of the crimes cases against persons.
crime case against persons refers to crime_against = 'Persons'
SELECT title, description FROM FBI_Code WHERE crime_against = 'Persons'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the average price of products with more than fifty units in stock?
more than fifty units in stock refers to UnitsInStock > 50; average price = avg(UnitPrice where UnitsInStock > 50)
SELECT SUM(UnitPrice) / COUNT(UnitPrice) FROM Products WHERE UnitsInStock > 50
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
chicago_crime
List the community area names in the Northwest.
the Northwest refers to side = 'Northwest'
SELECT community_area_name FROM Community_Area WHERE side = 'Northwest'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the difference in salary of the top 2 employees with the highest number of territories in charge?
highest number of territories refers to max(TerritoryID); difference in salary = subtract(employeeA.Salary, employeeB.Salary)
SELECT MAX(Salary) - MIN(Salary) FROM ( SELECT T1.Salary FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.EmployeeID, T1.Salary ORDER BY COUNT(T2.TerritoryID) DESC LIMIT 2 ) T1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
app_store
List all the comments on the lowest rated Mature 17+ app.
comments refers to Translated_Review; lowest rated refers to Rating = 1; Mature 17+ refers to Content Rating = 'Mature 17+ ';
SELECT T2.Translated_Review FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1."Content Rating" = 'Mature 17+' ORDER BY T1.Rating LIMIT 1
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
What is the alderman's full name of the most crowded ward?
alderman's full name refers to alderman_name_suffix, alderman_first_name, alderman_last_name; the most crowded refers to max(population)
SELECT alderman_name_suffix, alderman_first_name, alderman_last_name FROM Ward ORDER BY population DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
Among the seafood products, which product have the highest total production of the production?
seafood product refers to CategoryName = 'Seafood'; product refers to ProductID; highest total production refers to max(add(units in stock, units on order))
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Seafood' ORDER BY T1.UnitsInStock + T1.UnitsOnOrder DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
chicago_crime
Provide the responsible person and his/her email address of Chicago Lawn.
responsible person refers to commander; email address refers to email; Chicago Lawn refers to district_name = 'Chicago Lawn'
SELECT commander, email FROM District WHERE district_name = 'Chicago Lawn'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How many products were ordered in the order with the highest freight?
highest freight refers to max(Freight)
SELECT COUNT(T2.ProductID) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID GROUP BY T2.ProductID ORDER BY COUNT(T1.Freight) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
How many books were ordered in the last month of the year 2020?
ordered in last month of the year 2020 refers to Substr(order_date, 1, 7) = '2020-12'
SELECT COUNT(*) FROM cust_order WHERE order_date LIKE '2020-12%'
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, );
app_store
What is the total Sentiment polarity score of the most expensive app?
total sentiment polarity score = sum(Sentiment_Polarity); most expensive app refers to MAX(Price);
SELECT SUM(T2.Sentiment_Polarity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Price = ( SELECT MAX(Price) FROM playstore )
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
List the IUCR numbers and index status of homicide incidents.
index status refers to index_code; homicide incident refers to primary_description = 'HOMICIDE'
SELECT index_code FROM IUCR WHERE primary_description = 'HOMICIDE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the full name of the employee who handled the highest amount of orders?
full name refers to FirstName LastName; highest amount of orders refers to max(count(OrderID))
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.FirstName, T1.LastName ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
chicago_crime
How many domestic violence cases were reported in May 2018?
domestic violence refers to domestic = 'TRUE'; in May 2018 refers to date LIKE '5/%/2018%'
SELECT COUNT(*) FROM Crime WHERE date LIKE '5/%/2018%' AND domestic = 'TRUE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
Among the beverages, which product has the highest customer satisfaction?
beverage refers to CategoryName = 'Beverages'; highest customer satisfaction refers to max(ReorderLevel)
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Beverages' ORDER BY T1.ReorderLevel DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
app_store
Which 1,000,000,000+ intalls apps has the most no comment reviews?
no comment refers to Translated_Review = 'nan'; most no comment reviews = (MAX(COUNT(Translated_Review = 'nan')));
SELECT T1.App FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Installs = '1,000,000+' AND T2.Translated_Review = 'nan' GROUP BY T1.App ORDER BY COUNT(T2.Translated_Review) DESC LIMIT 1
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
How many vandalisms were arrested in the ward represented by Edward Burke?
vandalism refers to title = 'Vandalism'; arrested refers to arrest = 'TRUE'
SELECT SUM(CASE WHEN T1.alderman_last_name = 'Burke' THEN 1 ELSE 0 END) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no WHERE T3.title = 'Vandalism' AND T2.arrest = 'TRUE' AND T1.alderman_first_name = 'Edward'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the average number of territories do each sales representative is in charge of?
sales representative refers to Title = 'Sales Representative'; average number of territories = divide(count(TerritoryID) , count(EmployeeID)) where Title = 'Sales Representative'
SELECT CAST(COUNT(T2.TerritoryID) AS REAL) / COUNT(DISTINCT T1.EmployeeID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.Title = 'Sales Representative'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
Indicate the complete address of customers located in Lazaro Cardenas.
complete address refers to street_number, street_name, city, country; "Lazaro Cardenas" is the city
SELECT street_number, street_name, city, country_id FROM address WHERE city = 'Lazaro Cardenas'
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, );
chicago_crime
What is the name of the community that has the highest number of crimes related to prostitution?
name of the community refers to community_area_name; the highest number of crimes refers to max(case_number); prostitution refers to primary_description = 'PROSTITUTION'
SELECT T3.community_area_name FROM Crime AS T1 INNER JOIN IUCR AS T2 ON T1.iucr_no = T2.iucr_no INNER JOIN Community_Area AS T3 ON T1.community_area_no = T3.community_area_no WHERE T2.primary_description = 'PROSTITUTION' GROUP BY T1.iucr_no ORDER BY T1.case_number DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What are the territory descriptions of territories in the Eastern region?
in the Eastern region refers to RegionDescription = 'Eastern'
SELECT DISTINCT T1.TerritoryDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern' ORDER BY T1.TerritoryDescription
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
Indicate the title of the six books with the greatest potential value as collectibles.
greatest potential value refers to Min(publication_date)
SELECT title FROM book ORDER BY publication_date ASC LIMIT 6
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, );
app_store
Which Photography app has the highest total Sentiment subjectivity score?
Photography app refers to Genre = 'Photography'; highest total sentiment subjectivity score = MAX(sum(Sentiment_Subjectivity));
SELECT T1.App FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Genres = 'Photography' GROUP BY T1.App ORDER BY SUM(T2.Sentiment_Subjectivity) DESC LIMIT 1
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
What is the legislative district's office address where 010XX W LAKE ST is located?
the legislative district's office address refers to ward_office_address; 010XX W LAKE ST refers to block = '010XX W LAKE ST'
SELECT T1.ward_office_address FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.block = '010XX W LAKE ST' GROUP BY T1.ward_office_address
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
Which territories is the employee with a doctorate in charge of? List all of the territory descriptions.
with a doctorate refers to TitleOfCourtesy = 'Dr.'
SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.TitleOfCourtesy = 'Dr.'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
In which cities are the customers of Costa Rica located?
"Costa Rica" is the country_name
SELECT T1.city FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Costa Rica'
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, );
app_store
What is the number of neutral comments from all the weather apps?
neutral comments refers to Sentiment = 'Neutral'; weather app refers to Genre = 'Weather';
SELECT COUNT(T2.Sentiment) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Genres = 'Weather' AND T2.Sentiment = 'Neutral'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
What is the short description of the crime committed the most by criminals in the least populated community?
short description refers to title; committed the most refers to max(fbi_code_no); the least populated community refers to min(population)
SELECT T3.title FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no GROUP BY T3.title ORDER BY T1.population ASC, T3.fbi_code_no DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the most ordered products by customers?
most ordered refers to max(count(ProductID)); product refers to ProductID
SELECT T1.ProductID FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
app_store
What percentage of no comment reviews are from "Teen" content rating apps?
no comment refers to Translated_Review = 'nan'; percentage = DIVIDE((SUM(Content Rating = 'Teen')), COUNT(*));
SELECT CAST(COUNT(CASE WHEN T1.`Content Rating` = 'Teen' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.App) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T2.Translated_Review = 'nan'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
Out of all the incidents of domestic violence reported at the ward represented by alderman Walter Burnett Jr., how many were arrested?
domestic violence refers to domestic = 'TRUE'; arrested refers to arrest = 'TRUE'
SELECT SUM(CASE WHEN T2.arrest = 'TRUE' THEN 1 ELSE 0 END) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T1.alderman_first_name = 'Walter' AND T1.alderman_last_name = 'Burnett' AND alderman_name_suffix = 'Jr.' AND T2.domestic = 'TRUE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the title of the employee with the highest number of territories in charge?
highest number of territories refers to max(TerritoryID)
SELECT T1.Title FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.Title ORDER BY COUNT(T2.TerritoryID) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
app_store
What is the number of installments of the app with the highest total Sentiment polarity score?
installments refers to Installs; highest total sentiment polarity score = MAX(SUM(Sentiment_Polarity));
SELECT T1.Installs FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App GROUP BY T1.App ORDER BY SUM(T2.Sentiment_Polarity) DESC LIMIT 1
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
How many neighborhoods are there in Near North Side?
Near North Side refers to community_area_name = 'Near North Side'
SELECT SUM(CASE WHEN T1.community_area_name = 'Near North Side' THEN 1 ELSE 0 END) FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What are the names of the products that were ordered that have a unit price of no more than 5?
unit price of no more than 5 refers to UnitPrice < 5; name of products refers to ProductName
SELECT DISTINCT T1.ProductName FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.UnitPrice < 5
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
What is the full name of the customers who live in Baiyin city?
full name refers to first_name, last_name; 'Baiyin' is the city
SELECT T3.first_name, T3.last_name FROM address AS T1 INNER JOIN customer_address AS T2 ON T1.address_id = T2.address_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T1.city = 'Baiyin'
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, );
app_store
What is the rating and the total Sentiment subjectivity score of "Onefootball - Soccer Scores"?
Onefootball - Soccer Scores refers to App = 'Onefootball - Soccer Scores';
SELECT T1.Rating, SUM(T2.Sentiment_Subjectivity) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Onefootball - Soccer Scores'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
In the most populated ward, how many incidents of domestic violence were reported in a bar or tavern?
the most populated refers to max(population); domestic violence refers to domestic = 'TRUE'; in a bar or tavern refers to location_description = 'BAR OR TAVERN'
SELECT COUNT(T2.report_no) FROM Ward AS T1 INNER JOIN Crime AS T2 ON T1.ward_no = T2.ward_no WHERE T2.domestic = 'TRUE' AND T2.location_description = 'BAR OR TAVERN' ORDER BY T1.Population DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the name of the supplier that supplies the most products to the company?
name of the supplier refers to SupplierID; the most product refers to max(count(ProductID))
SELECT T1.SupplierID FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID GROUP BY T1.SupplierID ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
Indicate the full name of all customers whose last name begins with the letter K.
full name refers to first_name, last_name; last name begin with the letter 'K' refers to last_name LIKE 'K%'
SELECT first_name, last_name FROM customer WHERE last_name LIKE 'K%'
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, );
app_store
Which apps have been reviewed more than 75 000 000 times and the content is suitable for teenagers?
Reviews>75000000; suitable for teenagers refers to Content Rating = 'Teen';
SELECT DISTINCT App FROM playstore WHERE Reviews > 75000000 AND `Content Rating` = 'Teen'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
How many solicit on public way prostitution crimes were arrested in West Garfield Park?
solicit on public way prostitution crime refers to secondary_description = 'SOLICIT ON PUBLIC WAY' AND primary_description = 'PROSTITUTION'; arrested refers to arrest = 'TRUE'; West Garfield Park refers to community_area_name = 'West Garfield Park'
SELECT SUM(CASE WHEN T2.arrest = 'TRUE' THEN 1 ELSE 0 END) FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN IUCR AS T3 ON T2.iucr_no = T3.iucr_no WHERE T1.community_area_name = 'West Garfield Park' AND T3.secondary_description = 'SOLICIT ON PUBLIC WAY' AND T3.primary_description = 'PROSTITUTION'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How much is the total purchase price, including freight, of the top 2 most expensive products?
total purchase price including freight refers to add(multiply(UnitPrice , Quantity) , Freight); most expensive refers to max(UnitPrice)
SELECT T2.UnitPrice * T2.Quantity + T1.Freight FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID ORDER BY T2.UnitPrice * T2.Quantity + T1.Freight DESC LIMIT 2
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
chicago_crime
What is the precise location or coordinate where most of the robberies in Rogers Park occurred?
precise location or coordinate refers to latitude, longitude; most refers to fbi_code_no = 3; robbery refers to title = 'Robbery'; Rogers Park refers to community_area_name = 'Rogers Park'
SELECT T2.latitude, T2.longitude FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no WHERE T1.community_area_name = 'Rogers Park' AND T3.title = 'Robbery' AND T3.fbi_code_no = 3
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How many suppliers in Australia whose products were discontinued?
in Australia refers to Country = 'Australia'; discontinued refers to Discontinued = 1
SELECT COUNT(T1.Discontinued) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Discontinued = 1 AND T2.Country = 'Australia'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
On what date did the customers who live at number 460 of their respective streets place their orders?
live at number 460 refers to street_number = '460'; date the customers placed their orders refers to order_date
SELECT T1.order_date FROM cust_order AS T1 INNER JOIN address AS T2 ON T1.dest_address_id = T2.address_id WHERE T2.street_number = 460
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, );
shooting
Of the black officers, how many of them investigated cases between the years 2010 and 2015?
black refers to race = 'B'; between the years 2010 and 2015 refers to date between '2010-01-01' and '2015-12-31'; case refers to case_number
SELECT COUNT(T1.case_number) FROM officers AS T1 INNER JOIN incidents AS T2 ON T2.case_number = T1.case_number WHERE T1.race = 'B' AND T2.date BETWEEN '2010-01-01' AND '2015-12-31'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
chicago_crime
In Albany Park, how many arrests were made in an apartment due to criminal sexual abuse?
Albany Park refers to district_name = 'Albany Park'; in an apartment refers to location_description = 'APARTMENT'; criminal sexual abuse refers to title = 'Criminal Sexual Abuse'
SELECT SUM(CASE WHEN T3.title = 'Criminal Sexual Abuse' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no WHERE T1.district_name = 'Albany Park' AND T2.arrest = 'TRUE' AND T2.location_description = 'APARTMENT'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
In total, how many orders were shipped via United Package?
via United Package refers to CompanyName = 'United Package'
SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'United Package'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
Which customer addresses are no longer active?
no longer active refers to address_status = 'Inactive'; customer address refers to street_number, street_name, city
SELECT DISTINCT T1.street_name FROM address AS T1 INNER JOIN customer_address AS T2 ON T1.address_id = T2.address_id INNER JOIN address_status AS T3 ON T3.status_id = T2.status_id WHERE T3.address_status = 'Inactive'
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, );
app_store
What is the average price for a dating application?
average price = AVG(Price where Genre = 'Dating'); dating application refers to Genre = 'Dating';
SELECT AVG(Price) FROM playstore WHERE Genres = 'Dating'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
Which crime was committed the most by criminals?
crime refers to title; committed the most refers to max(fbi_code_no)
SELECT T2.title FROM Crime AS T1 INNER JOIN FBI_Code AS T2 ON T1.fbi_code_no = T2.fbi_code_no ORDER BY T2.fbi_code_no DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What are the names of the suppliers whose products have the highest user satisfaction?
name of the supplier refers to SupplierID; highest user satisfaction refers to max(ReorderLevel)
SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
What is the status of the orders placed on 04/10/2022?
placed on 04/10/2022 refers to SUBSTR(order_date, 1, 10) = '2022-04-10'; status of order refers to status_value
SELECT DISTINCT T1.status_value FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id WHERE T3.order_date LIKE '2022-04-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, );
app_store
Which apps have 5 rating? List out then application name.
application name refers to App;
SELECT DISTINCT App FROM playstore WHERE Rating = 5
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
Who is the commanding officer in the district with the highest number of disorderly conduct?
commanding officer refers to commander; the highest number refers to max(count(district_no)); disorderly conduct refers to title = 'Disorderly Conduct'
SELECT T1.commander FROM District AS T1 INNER JOIN Crime AS T2 ON T1.district_no = T2.district_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no WHERE T3.title = 'Disorderly Conduct' AND T2.fbi_code_no = 24 GROUP BY T2.fbi_code_no ORDER BY COUNT(T1.district_no) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How many orders were shipped to GREAL via United Package?
GREAL refers to CustomerID = 'GREAL'; via United Package refers to CompanyName = 'United Package'
SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.CustomerID = 'GREAL' AND T2.CompanyName = 'United Package'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
What is the email of the customers who place their orders with priority method?
priority method refers to method_name = 'Priority'
SELECT T1.email FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T3.method_name = 'Priority'
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, );
chicago_crime
Give the detailed description of all the crimes against society.
crime against society refers to crime_against = 'Society'
SELECT description FROM FBI_Code WHERE crime_against = 'Society'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How many products were supplied by Pavlova, Ltd.?
Pavlova, Ltd. refers to CompanyName = 'Pavlova, Ltd.'
SELECT COUNT(T1.ProductName) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Pavlova, Ltd.'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
app_store
List out genre that have downloads more than 1000000000.
downloads and installs are synonyms; Installs = '1,000,000,000+';
SELECT Genres FROM playstore WHERE Installs = '1,000,000,000+' GROUP BY Genres
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
How many arrests were made in 2018 in an animal hospital under FBI code 08B?
arrest refers to arrest = 'TRUE'; in 2018 refers to date LIKE '%2018%'; in an animal hospital refers to location_description = 'ANIMAL HOSPITAL'; FBI code 08B refers to fbi_code_no = '08B'
SELECT SUM(CASE WHEN arrest = 'TRUE' THEN 1 ELSE 0 END) FROM Crime WHERE date LIKE '%2018%' AND location_description = 'ANIMAL HOSPITAL' AND fbi_code_no = '08B'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the most widely used shipping company in the United States of America?
most widely used refers to max(count(ShipVia)); shipping company refers to CompanyName; in the United States of America refers to ShipCountry = 'USA'
SELECT T2.CompanyName FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.ShipCountry = 'USA' GROUP BY T2.CompanyName ORDER BY COUNT(T2.CompanyName) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
List the titles of all the books that Peter H. Smith wrote.
"Peter H.Smit" is the author_name
SELECT T1.title 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 = 'Peter H. Smith'
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, );
chicago_crime
What is the population of the district with the least population?
the least population refers = min(sum(population))
SELECT SUM(population) FROM Community_Area GROUP BY side ORDER BY SUM(population) LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the average salary of sales representatives in the United Kingdom?
average salary = avg(Salary); sales representative refers to Title = 'Sales Representative'; in the United Kingdom refers to Country = 'UK'
SELECT AVG(Salary) FROM Employees WHERE Title = 'Sales Representative' AND Country = 'UK'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
chicago_crime
How many incidents of domestic violence occurred in an abandoned building in 2018?
domestic violence refers to domestic = 'TRUE'; in an abandoned building refers to location_description = 'ABANDONED BUILDING'; in 2018 refers to date LIKE '%2018%'
SELECT SUM(CASE WHEN location_description = 'ABANDONED BUILDING' THEN 1 ELSE 0 END) FROM Crime WHERE date LIKE '%2018%' AND domestic = 'TRUE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What are the names of the products that were discountinued?
discontinued refers to Discontinued = 1; name of products refers to ProductName
SELECT ProductName FROM Products WHERE Discontinued = 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
Identify by their id all the orders that have been cancelled.
have been cancelled refers to status_value = 'cancelled'; id refers to order_id
SELECT T2.order_id FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Cancelled'
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, );
app_store
What is the average review number for application with 5 rating?
average review = AVG(Review); application refers to app; Rating = 5;
SELECT AVG(Reviews) FROM playstore WHERE Rating = 5
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
What is the name of the community with the highest population?
name of the community refers to community_area_name; the highest population refers to max(population)
SELECT community_area_name FROM Community_Area ORDER BY population DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the full name of the employee with the highest salary?
full name refers to FirstName LastName; highest salary refers to max(Salary)
SELECT FirstName, LastName FROM Employees WHERE Salary = ( SELECT MAX(Salary) FROM Employees )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
shooting
How many instances were found in June 2015?
in June 2015 refers to date between '2015-06-01' and '2015-06-30'; record number refers to case_number
SELECT COUNT(case_number) FROM incidents WHERE date BETWEEN '2015-06-01' AND '2015-06-30'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
chicago_crime
How many crimes were committed at 018XX S KOMENSKY AVEin May 2018?
in May 2018 refers to date LIKE '5/%/2018%'
SELECT SUM(CASE WHEN date LIKE '5/%/2018%' THEN 1 ELSE 0 END) FROM Crime WHERE block = '018XX S KOMENSKY AVE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
Which product have the highest user satisfaction?
product refers to ProductName; highest user satisfaction refers to max(ReorderLevel)
SELECT ProductName FROM Products WHERE ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
app_store
What is the percentage of application with 4.7 rating having more positives sentiment than negative sentiment?
percentage = DIVIDE(SUBTRACT(SUM(Sentiment = 'Positive')), (SUM(Sentiment = 'Negative')), SUM(Sentiment = 'Negative')) as percentage; having more positive sentiment than negative sentiment refers to Sentiment = 'Positive'>Sentiment = 'Negative';
SELECT CAST(COUNT(CASE WHEN ( SELECT COUNT(CASE WHEN Sentiment = 'Positive' THEN 1 ELSE NULL END) - COUNT(CASE WHEN Sentiment = 'Negative' THEN 1 ELSE NULL END) FROM user_reviews GROUP BY App ) > 0 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.Sentiment) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Rating = 4.7
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
What is the percentage of larceny cases among all cases that happened in Edgewater community?
larceny case refers to title = 'Larceny'; Edgewater community refers to community_area_name = 'Edgewater'; percentage = divide(count(case_number where title = 'Larceny'), count(case_number)) where community_area_name = 'Edgewater' * 100%
SELECT CAST(SUM(CASE WHEN T3.title = 'Larceny' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.case_number) FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no INNER JOIN FBI_Code AS T3 ON T2.fbi_code_no = T3.fbi_code_no WHERE T1.community_area_name = 'Edgewater'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How many suppliers are there in the United States of America?
United States of America refers to Country = 'USA'
SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'USA'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
On what dates were books ordered at a price of 16.54?
price of 16.54 refers to price = 16.54; dates the book ordered refers to order_date
SELECT T1.order_date FROM cust_order AS T1 INNER JOIN order_line AS T2 ON T1.order_id = T2.order_id WHERE T2.price = 16.54
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, );
app_store
What is the average download for entertainment apps with size no more than 1.0 M?
downloads and installs are synonyms; entertainment apps refers to Category = 'ENTERTAINMENT';
SELECT AVG(CAST(REPLACE(REPLACE(Installs, ',', ''), '+', '') AS INTEGER)) FROM playstore WHERE Category = 'ENTERTAINMENT' AND Size < '1.0M'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
What is the percentage of under $500 thefts among all cases that happened in West Englewood?
under $500 refers to secondary_description = '$500 AND UNDER'; theft refers to primary_description = 'THEFT'; West Englewood refers to community_area_name = 'West Englewood'; percentage = divide(count(case_number where secondary_description = '$500 AND UNDER'), count(case_number)) where primary_description = 'THEFT' and community_area_name = 'West Englewood' * 100%
SELECT CAST(SUM(CASE WHEN T2.secondary_description = '$500 AND UNDER' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.case_number) FROM Crime AS T1 INNER JOIN IUCR AS T2 ON T1.iucr_no = T2.iucr_no INNER JOIN Community_Area AS T3 ON T1.community_area_no = T3.community_area_no WHERE T2.primary_description = 'THEFT' AND T3.community_area_name = 'West Englewood'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the most expensive product?
product refers to ProductName; most expensive refers to max(UnitPrice)
SELECT ProductName FROM Products WHERE UnitPrice = ( SELECT MAX(UnitPrice) FROM Products )
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
How many books have been published in Japanese?
in Japanese refers to language_name = 'Japanese
SELECT COUNT(*) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'
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, );
app_store
List out the top 3 genre for application with a sentiment review greater than 0.5.
sentiment review refers to Sentiment_Polarity; Sentiment_Polarity>0.5;
SELECT Genres FROM playstore WHERE App IN ( SELECT App FROM user_reviews WHERE Sentiment = 'Positive' AND Sentiment_Polarity > 0.5 ORDER BY Sentiment_Polarity DESC LIMIT 3 )
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
Tell the number of cases with arrests in North Lawndale community.
number of cases refers to count(case_number); arrest refers to arrest = 'TRUE'; North Lawndale community refers to community_area_name = 'North Lawndale'
SELECT SUM(CASE WHEN T1.community_area_name = 'North Lawndale' THEN 1 ELSE 0 END) FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no WHERE T2.arrest = 'TRUE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What is the Island Trading customer's complete address?
Island Trading refers to CompanyName = 'Island Trading'; complete address = Address, City, Region, Country, PostalCode
SELECT Address, City, Region, Country, PostalCode FROM Customers WHERE CompanyName = 'Island Trading'
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
What is the highest price at which a customer bought the book 'The Prophet'?
"The Prophet" is the title of the book; highest price refers to Max(price)
SELECT MAX(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'The Prophet'
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, );
app_store
List down application that have not been updated since 2015. What is the percentage of this application having more negative sentiment than positive sentiment?
percentage = DIVIDE(SUBTRACT(SUM(Sentiment = 'Positive')), (SUM(Sentiment = 'Negative'))), (SUM(Sentiment = 'Negative')) as percent; Last Updated>'2015';
SELECT CAST((( SELECT COUNT(*) Po FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE SUBSTR(T1."Last Updated", -4, 4) > '2015' AND T2.Sentiment = 'Positive' ) - ( SELECT COUNT(*) Ne FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE SUBSTR(T1."Last Updated", -4, 4) > '2015' AND T2.Sentiment = 'Negative' )) AS REAL) * 100 / ( SELECT COUNT(*) NUM FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE SUBSTR(T1."Last Updated", -4, 4) > '2015' )
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );
chicago_crime
Give the FBI code description of case No.JB134191.
case No.JB134191 refers to case_number = 'JB134191'
SELECT description FROM Crime AS T1 INNER JOIN FBI_Code AS T2 ON T1.fbi_code_no = T2.fbi_code_no WHERE T1.case_number = 'JB134191'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
What are the order ids of the orders with freight of over 800?
freight of over 800 refers to Freight > 800
SELECT OrderID FROM Orders WHERE Freight > 800
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
shooting
How many people were injured between 2006 and 2014 as a result of a handgun?
injured refers to subject_statuses = 'injured'; between 2006 and 2014 refers to date between '2006-01-01' and '2013-12-31'; handgun refers to subject_weapon = 'handgun'; where the incidents took place refers to location
SELECT COUNT(location) FROM incidents WHERE subject_weapon = 'Handgun' AND subject_statuses = 'Injured' AND date BETWEEN '2006-01-01' AND '2013-12-31'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
chicago_crime
How many different neighborhoods are there in Roseland community?
Roseland community refers to community_area_name = 'Roseland'
SELECT SUM(CASE WHEN T1.community_area_name = 'Roseland' THEN 1 ELSE 0 END) FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Values: `Far North `, `North `, `Central`, `Northwest `, `West ` | Value Statics: Total count 77 - Distinct count 9 - Null count 0 community_area_no INTEGER primary key, community_area_name TEXT, -- ); CREATE TABLE Ward ( ward_office_address TEXT, -- ward_office_zip TEXT, -- city_hall_office_phone TEXT, -- alderman_first_name TEXT, -- ward_no INTEGER primary key, ward_email TEXT, -- ward_office_fax TEXT, -- alderman_last_name TEXT, -- Population INTEGER, -- alderman_name_suffix TEXT, -- Example Values: `Jr.` | Value Statics: Total count 5 - Distinct count 1 - Null count 45 ward_office_phone TEXT, -- city_hall_office_room INTEGER, -- Example Values: `200`, `305`, `300`, `302` | Value Statics: Total count 50 - Distinct count 4 - Null count 0 city_hall_office_fax TEXT, -- ); CREATE TABLE IUCR ( iucr_no TEXT primary key, index_code TEXT, -- Example Values: `I`, `N` | Value Statics: Total count 401 - Distinct count 2 - Null count 0 primary_description TEXT, -- secondary_description TEXT, -- ); CREATE TABLE FBI_Code ( description TEXT, -- fbi_code_no TEXT primary key, crime_against TEXT, -- Example Values: `Persons`, `Property`, `Society`, `Persons and Society` | Value Statics: Total count 26 - Distinct count 4 - Null count 0 title TEXT, -- ); CREATE TABLE Neighborhood ( foreign key (community_area_no) references Community_Area(community_area_no), community_area_no INTEGER, -- neighborhood_name TEXT primary key, ); CREATE TABLE Crime ( case_number TEXT, -- longitude TEXT, -- foreign key (fbi_code_no) references FBI_Code(fbi_code_no), fbi_code_no TEXT, -- date TEXT, -- arrest TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 foreign key (community_area_no) references Community_Area(community_area_no), location_description TEXT, -- latitude TEXT, -- block TEXT, -- ward_no INTEGER, -- domestic TEXT, -- Example Values: `FALSE`, `TRUE` | Value Statics: Total count 100000 - Distinct count 2 - Null count 0 district_no INTEGER, -- report_no INTEGER primary key, iucr_no TEXT, -- foreign key (ward_no) references Ward(ward_no), community_area_no INTEGER, -- foreign key (district_no) references District(district_no), foreign key (iucr_no) references IUCR(iucr_no), beat INTEGER, -- );
retail_world
How many customers are there in the country with the highest number of customers?
highest number refers to max(count(CustomerID))
SELECT COUNT(CustomerID) FROM Customers GROUP BY Country ORDER BY COUNT(CustomerID) DESC LIMIT 1
CREATE TABLE Products ( CategoryID INTEGER, -- Example Values: `1`, `2`, `7`, `6`, `8` | Value Statics: Total count 77 - Distinct count 8 - Null count 0 Unit TEXT, -- ReorderLevel INT, -- ProductName TEXT, -- Price REAL DEFAULT 0, -- FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID), SupplierID INTEGER, -- ProductID INTEGER PRIMARY KEY AUTOINCREMENT, FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID), ); CREATE TABLE Customers ( ContactName TEXT, -- Country TEXT, -- Address TEXT, -- City TEXT, -- CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, PostalCode TEXT, -- CustomerName TEXT, -- ); CREATE TABLE EmployeeTerritories ( TerritoryID INT, -- EmployeeID INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE OrderDetails ( Quantity INTEGER, -- FOREIGN KEY (OrderID) REFERENCES Orders (OrderID), OrderID INTEGER, -- FOREIGN KEY (ProductID) REFERENCES Products (ProductID), OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT, ProductID INTEGER, -- ); CREATE TABLE Shippers ( ShipperID INTEGER PRIMARY KEY AUTOINCREMENT, ShipperName TEXT, -- Example Values: `Speedy Express`, `United Package`, `Federal Shipping` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 Phone TEXT, -- Example Values: `(503) 555-9831`, `(503) 555-3199`, `(503) 555-9931` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE Territory ( TerritoryDescription TEXT, -- RegionID INTEGER, -- TerritoryID INTEGER PRIMARY KEY AUTOINCREMENT, ); CREATE TABLE EmployeeDetails ( EmployeeID INT PRIMARY KEY, Title TEXT, -- Salary INT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), ); CREATE TABLE Categories ( CategoryID INTEGER PRIMARY KEY AUTOINCREMENT, CategoryName TEXT, -- Example Values: `Beverages`, `Condiments`, `Confections`, `Dairy Products`, `Grains/Cereals` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 Description TEXT, -- Example Values: `Soft drinks, coffees, teas, beers, and ales`, `Sweet and savory sauces, relishes, spreads, and seasonings`, `Desserts, candies, and sweet breads`, `Cheeses`, `Breads, crackers, pasta, and cereal` | Value Statics: Total count 8 - Distinct count 8 - Null count 0 ); CREATE TABLE Employees ( Photo TEXT, -- Example Values: `EmpID1.pic`, `EmpID2.pic`, `EmpID3.pic`, `EmpID4.pic`, `EmpID5.pic` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 Notes TEXT, -- Example Values: `Education includes a BA in psychology from Colorado State University. She also completed (The Art of the Cold Call). Nancy is a member of 'Toastmasters International'.`, `Andrew received his BTS commercial and a Ph.D. in international marketing from the University of Dallas. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager and was then named vice president of sales. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.`, `Janet has a BS degree in chemistry from Boston College). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate and was promoted to sales representative.`, `Margaret holds a BA in English literature from Concordia College and an MA from the American Institute of Culinary Arts. She was temporarily assigned to the London office before returning to her permanent post in Seattle.`, `Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree. Upon joining the company as a sales representative, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London, where he was promoted to sales manager. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management'. He is fluent in French.` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 BirthDate DATE, -- Example Values: `1968-12-08`, `1952-02-19`, `1963-08-30`, `1958-09-19`, `1955-03-04` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT, FirstName TEXT, -- Example Values: `Nancy`, `Andrew`, `Janet`, `Margaret`, `Steven` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 LastName TEXT, -- Example Values: `Davolio`, `Fuller`, `Leverling`, `Peacock`, `Buchanan` | Value Statics: Total count 10 - Distinct count 10 - Null count 0 ); CREATE TABLE Suppliers ( PostalCode TEXT, -- Address TEXT, -- SupplierID INTEGER PRIMARY KEY AUTOINCREMENT, City TEXT, -- Country TEXT, -- Example Values: `UK`, `USA`, `Japan`, `Spain`, `Australia` | Value Statics: Total count 29 - Distinct count 16 - Null count 0 Discontinued INTEGER DEFAULT 0, -- Example Values: `0` | Value Statics: Total count 29 - Distinct count 1 - Null count 0 ContactName TEXT, -- Phone TEXT, -- SupplierName TEXT, -- ); CREATE TABLE EmployeesExtra ( Salary INTEGER, -- Title TEXT, -- FOREIGN KEY (EmployeeID) REFERENCES Employees(EmployeeID), EmployeeID INTEGER PRIMARY KEY, ); CREATE TABLE discontinued_products ( Discontinued INTEGER, -- ProductID INTEGER PRIMARY KEY, ); CREATE TABLE Orders ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerID INTEGER, -- FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID), FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID), FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID), ShipperID INTEGER, -- Example Values: `3`, `1`, `2` | Value Statics: Total count 196 - Distinct count 3 - Null count 0 OrderDate DATETIME, -- EmployeeID INTEGER, -- Example Values: `5`, `6`, `4`, `3`, `9` | Value Statics: Total count 196 - Distinct count 9 - Null count 0 ); CREATE TABLE Territories ( TerritoryDescription TEXT, -- RegionDescription TEXT, -- ); CREATE TABLE ShippingInfo ( ShipCountry TEXT, -- ShippedDate DATETIME, -- FOREIGN KEY (OrderID) REFERENCES Orders(OrderID), OrderID INTEGER PRIMARY KEY, );
books
How many books under 300 pages has HarperCollins Publishers published?
under 300 pages refers to num_pages < 300; 'HarperCollins Publishers" is the publisher_name
SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'HarperCollins Publishers' AND T1.num_pages < 300
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, );
app_store
What genre does Honkai Impact 3rd belong to?
Honkai Impact 3rd is the App;
SELECT DISTINCT Genres FROM playstore WHERE App = 'Honkai Impact 3rd'
CREATE TABLE playstore ( Rating REAL, -- Size TEXT, -- App TEXT, -- Category TEXT, -- Price TEXT, -- "Content Rating" TEXT, -- Example Values: `Everyone`, `Teen`, `Everyone 10+`, `Mature 17+`, `Adults only 18+` | Value Statics: Total count 10840 - Distinct count 6 - Null count 0 Installs TEXT, -- Type TEXT, -- Example Values: `Free`, `Paid`, `NaN` | Value Statics: Total count 10840 - Distinct count 3 - Null count 0 Reviews INTEGER, -- Genres TEXT, -- ); CREATE TABLE user_reviews ( Sentiment TEXT, -- Example Values: `Positive`, `nan`, `Neutral`, `Negative` | Value Statics: Total count 64286 - Distinct count 4 - Null count 0 App TEXT references "playstore" (App), -- Translated_Review TEXT, -- Sentiment_Subjectivity TEXT, -- Sentiment_Polarity TEXT, -- );