db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
simpson_episodes
What are the keywords of the episodes which have the air date in 2008?
have air date in 2008 refers to air_date LIKE '2008%'
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE SUBSTR(T1.air_date, 1, 4) = '2008';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many online sales were made in May 2018 where products were shipped from Norman?
online sales refer to OrderNumber where Sales Channel = 'Online'; May 2018 refers to OrderDate LIKE '5/%/18'; Norman is the name of the city;
SELECT SUM(CASE WHEN T1.OrderDate LIKE '5/%/18' AND T1.`Sales Channel` = 'Online' AND T2.`City Name` = 'Norman' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
works_cycles
Please give the highest product cost of a purchase order.
product cost refers to ActualCost; purchase order refers to TransactionType = 'P';
SELECT ActualCost FROM TransactionHistory WHERE TransactionType = 'P' ORDER BY ActualCost DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Which currency pair's average exchange rate for the day is the highest?
currency pair refers to FromCurrencyCode/ToCurrencyCode
SELECT FromCurrencyCode, ToCurrencyCode FROM CurrencyRate ORDER BY AverageRate DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Which are the years that character Mr. Burns won an award?
null
SELECT DISTINCT T1.year FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T2.character = 'Mr. Burns';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
car_retails
List all the name of customers who have orders that are still processing.
Still processing refers to status = 'In Process';
SELECT t2.customerName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.status = 'In Process'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
Among the sales with a tax applied to retail transaction, how many of them are charged by multiple types of taxes?
tax applied to retail transaction refers to Taxtype = 1; sales that are charged with multiple types of tax refers to NAME LIKE '%+%';
SELECT COUNT(SalesTaxRateID) FROM SalesTaxRate WHERE Name LIKE '%+%'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
What is the total profit all transactions with product ID 827?
Profit = MULTIPLY(SUBTRACT(ListPrice, StandardCost) Quantity))
SELECT SUM((T1.ListPrice - T1.StandardCost) * T2.Quantity) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID = 827
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What are the keywords of the episode which has title as Dangerous Curves?
null
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Dangerous Curves';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Find the net profit of the floral products which were delivered in 2021.
floral product refers to Product Name = 'Floral'; total net profit = SUM(Subtract(Unit Price, Unit Cost)); delivered in 2021 refers to DeliveryDate LIKE '%/21'
SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T1.DeliveryDate LIKE '%/%/21' AND T2.`Product Name` = 'Floral'
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
Find the customer who made the highest payment in 2005.
The highest payment refers to max(amount); 2005 refers to year(paymentDate);
SELECT t2.customerName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t1.paymentDate) = '2005' GROUP BY t2.customerNumber, t2.customerName ORDER BY SUM(t1.amount) DESC LIMIT 1
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
How many salespersons haven't met quota?
salesperson that haven't met the quota refers to Bonus = 0;
SELECT COUNT(BusinessEntityID) FROM SalesPerson WHERE Bonus = 0
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List the name and calculate its profit for product with the highest rating in review.
Profit = SUBTRACT(ListPrice, StandardCost); the highest rating in review refers to Rating = 5
SELECT T1.Name, T1.ListPrice - T1.StandardCost FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.Rating DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
State the birth name of crews who are director and have birth country in South Korea.
director refers to role = 'director'
SELECT T1.birth_name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.role = 'director' AND T1.birth_country = 'South Korea';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
works_cycles
What is the average lead time of product ID 843? Calculate for its profit on net and indicate the full location to which the vendor is located.
Profit on net = SUBTRACT(LastReceiptCost, StandardPrice); full location = AddressLine1+AddressLine2+City+PostalCode;
SELECT T1.AverageLeadTime, T1.LastReceiptCost - T1.StandardPrice, T4.AddressLine1, T4.AddressLine2 , T4.City, T4.PostalCode FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN BusinessEntityAddress AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID INNER JOIN Address...
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List all products with minimum order quantity of 100 and order them by product name in descending order.
miinimum order quantity refers to MinOrderQty = 100
SELECT DISTINCT T1.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MinOrderQty = 100 ORDER BY T1.Name DESC
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the credited cast for the episode "In the Name of the Grandfather"?
credited cast refers to category = 'Cast' and  credited = 'true'; episode "In the Name of the Grandfather" refers to title = 'In the Name of the Grandfather'
SELECT DISTINCT T2.person FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'In the Name of the Grandfather' AND T2.category = 'Cast' AND T2.credited = 'true';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Compare the total number of orders between customer "Apollo Ltd" and "Pacific Ltd".
"Apollo Ltd" and "Pacific Ltd" are both Customer Names; total number of orders refers to COUNT(OrderNumber)
SELECT SUM(CASE WHEN T2.`Customer Names` = 'Apollo Ltd' THEN 1 ELSE 0 END), SUM(CASE WHEN T2.`Customer Names` = 'Pacific Ltd' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
How many 2001 Ferrari Enzo were ordered?
2001 Ferrari Enzo refers to productName;
SELECT SUM(t1.orderNumber) FROM orderdetails AS t1 INNER JOIN products AS t2 ON t1.productCode = t2.productCode WHERE t2.productName = '2001 Ferrari Enzo'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the highest amount of difference between the ordered quantity and actual quantity received in a single purchase order and to which vendor was the purchase order made?
highest amount of difference between the ordered quantity and actual quantity received in a single purchase order refers to MAX(SUBTRACT(OrderQty, ReceivedQty));
SELECT T2.OrderQty - T2.ReceivedQty, VendorID FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID ORDER BY T2.OrderQty - T2.ReceivedQty DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Which product has the highest profit on net? State the product name.
Profit on net = SUBTRACT(LastReceiptCost, StandardPrice)
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.LastReceiptCost - T2.StandardPrice DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List down the names of person born in California, USA.
California refers to birth_region = 'California'; USA refers to birth_country = 'USA'
SELECT name FROM Person WHERE birth_region = 'California' AND birth_country = 'USA';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
car_retails
Who are the sales representatives in New York City? List their full names.
New York City refers to city = 'NYC'; sales representative refers to jobTitle = 'Sales Rep';
SELECT t1.lastName, t1.firstName FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t2.city = 'NYC' AND t1.jobTitle = 'Sales Rep'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the total profit gained by the company from the product that has the highest amount of quantity ordered from online customers? Indicate the name of the product.
profit = MULTIPLY(SUBTRACT(ListPrice, Standardcost)), (Quantity)));
SELECT (T2.ListPrice - T2.StandardCost) * SUM(T1.Quantity), T2.Name FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T2.Name, T2.ListPrice, T2.StandardCost, T1.Quantity ORDER BY SUM(T1.Quantity) DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Among the low quality product, which product has the highest line total? List the product name and its line total?
Low quality refers to the product's quality class, therefore Class = 'L'
SELECT T1.Name, T2.LineTotal FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE Class = 'L' ORDER BY OrderQty * UnitPrice DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
car_retails
How many transactions payment made by customer that is lower than 10000. Group the result by year.
Transactions payment lower than 10000 refer to COUNT(amount) < 1000; by year refers to YEAR(paymentDate)
SELECT STRFTIME('%Y', t1.paymentDate), COUNT(t1.customerNumber) FROM payments AS t1 WHERE t1.amount < 10000 GROUP BY STRFTIME('%Y', t1.paymentDate)
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the full name of the second oldest person in the company at the time he was hired?
age at the time of being hired = SUBTRACT(HireDate, BirthDate); full name = FirstName+MiddleName+LastName;
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1, 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
What is the total ordered quantity for products under the 'Touring' line?
The Touring line refers to the product line, therefore ProductLine = 'T'
SELECT SUM(T2.OrderQty) FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'T'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Among the episodes which have star score less than 8, how many episodes were aired in 2009?
star score less than 8 refers to stars < 8; aired in 2009 refers to air_date LIKE '2009%'
SELECT COUNT(DISTINCT T2.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE strftime('%Y', T1.air_date) = '2009' AND T2.stars < 8;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Name the products via wholesale channel of the store under Pacific/Honolulu time zone.
products refers to Product Name; via wholesale channel refers to Sales Channel = 'Wholesale'
SELECT T FROM ( SELECT DISTINCT CASE WHEN T3.`Time Zone` = 'Pacific/Honolulu' AND T2.`Sales Channel` = 'Wholesale' THEN T1.`Product Name` ELSE NULL END AS T FROM Products T1 INNER JOIN `Sales Orders` T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` T3 ON T3.StoreID = T2._StoreID ) WHERE T IS NOT NULL
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
Identify the customer and list down the country with the check number GG31455.
null
SELECT t2.customerName, t2.country FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'GG31455'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the full name of the sales person who has the the highest commission percent received per sale?
commision percent received per sale refers to CommissionPct; highest commision percent received per sale refers to MAX(CommissionPcT); full name = FirstName+MiddleName+LastName;
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.CommissionPct DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List all product names and its product line for all purchase order with order quantity of 5000 or more.
Purchase order with order quantity of 5000 or more refers to OrderQty> = 5000
SELECT T1.Name, T1.ProductLine FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderQty > 4999
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the total number of episode with a rating below 7?
rating below 7 refers to rating < 7
SELECT COUNT(episode_id) FROM Episode WHERE rating < 7;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
works_cycles
What product has the fewest online orders from one customer? List the product's class, line of business, and list price.
fewest online orders refer to MIN(Quantity);
SELECT T2.Class, T2.ProductLine, T2.ListPrice FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY SUM(Quantity) LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Among all products without any rejected quantity, which product has the highest line total? State the product name and unit price.
Product without any rejected quantity refers to RejectedQty = 0
SELECT T1.Name, T2.UnitPrice FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.RejectedQty = 0 ORDER BY T2.LineTotal DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
regional_sales
Find the store ID with more orders between "Aurora" and "Babylon" city.
"Aurora" refers to City Name = 'Aurora (Township)'; "Babylon" refers to City Name = 'Babylong (Town)'; more order refers to Max(Count(OrderNumber))
SELECT T2.StoreID FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.`City Name` = 'Aurora (Township)' OR T2.`City Name` = 'Babylon (Town)' GROUP BY T2.StoreID ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
What is the percentage of employees are in Paris office?
DIVIDE(COUNT(employeeNumber) when city = 'Paris'), (COUNT(employeeNumber)) as percentage;
SELECT CAST(COUNT(CASE WHEN t1.city = 'Paris' THEN t2.employeeNumber ELSE NULL END) AS REAL) * 100 / COUNT(t2.employeeNumber) FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
How frequently does the first-ever Scheduling Assistant get paid?
PayFrequency = 1 refers to ‘Salary received monthly’; PayFrequency = 2 refers to ‘Salary received biweekly';
SELECT T2.PayFrequency FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Scheduling Assistant' ORDER BY T1.HireDate LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List the purchase order whereby all received quantity were rejected? Name those product.
Rejected refers rejected product in which to RejectedQty = 1
SELECT T1.Name FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.RejectedQty = T2.ReceivedQty AND T2.RejectedQty <> 0
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Give the title of the episode won in Primetime Emmy Awards 2009.
won refers to result = 'Winner'; in Primetime Emmy Awards refers to organization = 'Primetime Emmy Awards'; 2009 refers to year = 2009
SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.organization = 'Primetime Emmy Awards' AND T1.year = 2009 AND T1.result = 'Winner';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
List the name of the customer with the most number of order quantity from 2018 to 2020.
name of customer refers to Customer Names; from 2018 to 2020 refers to OrderDate between '1/1/2018' and '31/12/2020'; most number of order quantity refers to Order Quantity = 8
SELECT T1.`Customer Names` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID WHERE T2.OrderDate LIKE '%/%/18' OR T2.OrderDate LIKE '%/%/19' OR T2.OrderDate LIKE '%/%/20' ORDER BY T2.`Order Quantity` DESC LIMIT 1
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
List out 3 best seller products during year 2003 with their total quantity sold during 2003.
Best selling products refer to products with MAX(quantityOrdered); 2003 refers to year(orderDate) = 2003;
SELECT t3.productName, SUM(t2.quantityOrdered) FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t2.productCode = t3.productCode WHERE STRFTIME('%Y', t1.orderDate) = '2003' GROUP BY t3.productName ORDER BY SUM(t2.quantityOrdered) DESC LIMIT 3
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What are the names of the vendors to which the company purchased its women's tights products?
product is purchased refers to MakeFlag = 0; women's refers to Style = 'W'; ProductSubcategoryID = 'Tights';
SELECT DISTINCT T4.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN ProductSubcategory AS T3 ON T1.ProductSubcategoryID = T3.ProductSubcategoryID INNER JOIN Vendor AS T4 ON T2.BusinessEntityID = T4.BusinessEntityID WHERE T1.MakeFlag = 0 AND T1.Style = 'W' AND T3.Name = 'T...
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
How many people reviewed for product named HL Mountain Pedal? What is the average rating?
AVG(Rating) = DIVIDE(SUM(rating), COUNT(ReviewerName))
SELECT COUNT(T1.ProductID), AVG(T2.Rating) FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'HL Mountain Pedal'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
How many awards did simpson 20 won in 2009?
won refers to result = 'Winner'; in 2009 refers to year = 2009
SELECT COUNT(award_id) FROM Award WHERE SUBSTR(year, 1, 4) = '2009' AND result = 'Winner';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Please indicate store id in the state of California that have been applied 20% discount in store.
"California" is the name of State; in store refers to Sales Channel = 'In-Store'; 20% discount refers to Discount Applied = '0.2'
SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.State = 'California' AND T1.`Sales Channel` = 'In-Store' AND T1.`Discount Applied` = 0.2 THEN T2.StoreID END AS T FROM `Sales Orders` T1 INNER JOIN `Store Locations` T2 ON T2.StoreID = T1._StoreID ) WHERE T IS NOT NULL
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
Please list the order number of the customer whose credit card has a limit of 45300.
Credit card does not have a limit refers to creditLimit = 45300;
SELECT t1.orderNumber FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.creditLimit = 45300
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
How much is the average salary of female employees in comparison to male employees?
female refers to Gender = 'F'; male refers to Gender = 'M'; difference in the average salary of female against male employees = SUBTRACT(AVG(Rate where Gender = 'F')), (AVG(Rate where Gender = 'M')));
SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List down the product name, reviewer name, rating and comments for product under the road line.
The Road line refers to the product line, therefore ProductLine = 'R'
SELECT T1.Name, T2.ReviewerName, T2.Rating, T2.Comments FROM Product AS T1 INNER JOIN ProductReview AS T2 USING (productID) WHERE T1.ProductLine = 'R'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
regional_sales
List the order numbers and product names which were ordered on 6th June, 2018.
ordered on 6th June 2018 refers to OrderDate = '6/5/18'
SELECT DISTINCT OrderNumber, `Product Name` FROM ( SELECT IIF(T2.OrderDate = '6/6/18', T2.OrderNumber, NULL) AS "OrderNumber" , IIF(T2.OrderDate = '6/6/18', T1.`Product Name`, NULL) AS "Product Name" FROM Products T1 INNER JOIN `Sales Orders` T2 ON T2._ProductID = T1.ProductID ) WHERE OrderNumber IS NOT NULL AND `Produ...
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
When was the product with the highest unit price shipped?
The highest unit price refers to MAX(priceEach); when shipped refers to shippedDate;
SELECT t1.shippedDate FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber ORDER BY t2.priceEach DESC LIMIT 1
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
How many work orders with quantities ranging from 100 to 250 have a reorder point of no more than 375?
work order refers to TransactionType = 'W'; Quantity BETWEEN 100 AND 250; ReorderPoint< = 375;
SELECT COUNT(T1.TransactionID) FROM TransactionHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Quantity BETWEEN 100 AND 250 AND T2.ReorderPoint <= 375
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Calculate the profit of each products. List all products with more than $100 in profit.
Profit = AVG(SUBTRACT(ListPrice, StandardCost)>100
SELECT DISTINCT Name FROM Product WHERE ListPrice - StandardCost > 100
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the episode ID that received 2 stars and 9 votes?
2 stars refers to stars = 2; 9 votes refers to votes = 9
SELECT episode_id FROM Vote WHERE stars = 2 AND votes = 9;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Write down the store IDs and region of the state "Michigan".
"Michigan" is the State
SELECT DISTINCT T2.StoreID, T1.Region FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.State = 'Michigan'
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
For Which order was the most profitable, please list the customer name of the order and the profit of the order.
Most profitable order can be computed as MAX(MULTIPLY(quantityOrdered, SUBTRACT(priceEach, buyPrice)).
SELECT t3.customerName, (t1.priceEach - t4.buyPrice) * t1.quantityOrdered FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode GROUP BY t3.customerName, t1.price...
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What was the first job position that the company needed, and who was hired? Indicate his/her full name.
job position and job title are synonyms; full name = FirstName+MiddleName+LastName;
SELECT T1.JobTitle, T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.HireDate LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
State the product name, product line, rating and the selling price of product with the lowest rating.
Product with the lowest rating refers to the rating given by the reviewer where Rating = 1
SELECT T1.Name, T1.ProductLine, T2.Rating, T1.ListPrice FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.Rating ASC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Who did "The Tiny Canadian" play as in the show?
"The Tiny Canadian" refers to nickname = 'The Tiny Canadian'; play as in the show refers to role
SELECT T2.role FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T1.nickname = 'The Tiny Canadian';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
car_retails
Among the customers of empolyee 1370, who has the highest credit limit?Please list the full name of the contact person.
Employee 1370 refers to employeeNumber = '1370';
SELECT t2.contactFirstName, t2.contactLastName FROM employees AS t1 INNER JOIN customers AS t2 ON t1.employeeNumber = t2.salesRepEmployeeNumber WHERE t1.employeeNumber = '1370' ORDER BY t2.creditLimit DESC LIMIT 1
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
Jill ranked which medium-quality class product as the highest, and how long will it take the company to manufacture such a product?
second-lowest rating refers to Rating = 2; high-quality class product refers to Class = 'H'; length of time it takes the company to manufacture a product refers to DaysToManufacture;
SELECT T1.DaysToManufacture FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = 5 AND T1.Class = 'M' ORDER BY T2.Rating LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Provide details of review from reviewer whose name begin with letter 'J'. State the product ID, rating and comments.
reviewer whose name begin with letter 'J' = ReviewerName LIKE 'J%'
SELECT ProductID, Rating, Comments FROM ProductReview WHERE ReviewerName LIKE 'J%'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Among the episode with highest votes, what is the category credited to Carlton Batten?
highest votes refers to max(votes); to Carlton Batten refers to person = 'Carlton Batten'
SELECT T2.category FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Carlton Batten' AND T2.credited = 'true' ORDER BY T1.votes DESC LIMIT 1;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Count the number of orders made from the store in city with population of 3000000 to 4000000.
number of order refers to OrderNumber; population of 3000000 to 4000000 refers to Population BETWEEN 3000000 AND 4000000
SELECT COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.Population BETWEEN 3000000 AND 4000000
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
How many motorcycles have been ordered in 2004?
Motorcycles refer to productLine = 'motorcycles'; ordered in 2004 refers to year(orderDate) = 2004;
SELECT SUM(t2.quantityOrdered) FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t2.productCode = t3.productCode WHERE t3.productLine = 'motorcycles' AND STRFTIME('%Y', t1.orderDate) = '2004'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
As of 12/31/2011, how long has the employee assigned to all pending for approval papers been working in the company from the date he was hired?
pending for approval papers refer to Status = 1; length of stay in the company as of 12/31/2011 = SUBTRACT(2011, year(HireDate));
SELECT 2011 - STRFTIME('%Y', T2.HireDate) FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Which product line has the most products that are salable?
Saleable product refers to FinishedGoodsFlag = 1
SELECT ProductLine FROM Product WHERE FinishedGoodsFlag = 1 GROUP BY ProductLine ORDER BY COUNT(FinishedGoodsFlag) DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
regional_sales
List down the customer names and product names of the order made by "Anthony Torres" via distributor channel.
"Anthony Torres" is the name of Sales Team; distributor channel refers to Sales Channel = 'Distributor'
SELECT DISTINCT T1.`Customer Names`, T4.`Product Name` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID INNER JOIN Products AS T4 ON T4.ProductID = T2._ProductID WHERE T3.`Sales Team` = 'Anthony Torres' AND T2.`Sales...
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
How much did customer 103 pay in total?
Pay in total refers to SUM(amount);
SELECT SUM(t.amount) FROM payments t WHERE t.customerNumber = '103'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the salary rate per hour that the company paid to the first 5 employees that they hired?
salary rate per hour refers to Rate; first 5 employees that were hired refers to 5 oldest HireDate;
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID ORDER BY T2.HireDate ASC LIMIT 0, 5
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List all product names that are high in quality. Please also state its selling price.
High quality refers to the product's quality class, therefore Class = 'H'
SELECT Name, ListPrice FROM Product WHERE Class = 'H'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
In between the episode 5 and10 of season 2, how many of them are credited for casting?
between the episode 5 and 10 of season 20 refers to episode_id IN('S20-E5', 'S20-E6', 'S20-E7', 'S20-E8', 'S20-E9', 'S20-E10'); credited refers to credited = 'true'; for casting refers to role = 'casting'
SELECT COUNT(credited) FROM Credit WHERE episode_id IN ( 'S20-E5', 'S20-E6', 'S20-E7', 'S20-E8', 'S20-E9', 'S20-E10' ) AND credited = 'true' AND role = 'casting';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many sales teams are there in the Midwest?
"Midwest" is the Region
SELECT SUM(CASE WHEN Region = 'Midwest' THEN 1 ELSE 0 END) FROM `Sales Team`
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
How many 2003 Harley-Davidson Eagle Drag Bikes were ordered?
2003 Harley-Davidson Eagle Drag Bikes refers to productName; how many ordered refers to COUNT(quantityOrdered);
SELECT SUM(t2.quantityOrdered) FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode WHERE t1.productName = '2003 Harley-Davidson Eagle Drag Bike'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the profit of a single product that received the highest rating from John Smith? List the product/s' names.
highest rating refers to Rating = 5; profit = SUBTRACT(ListPrice, StandardCost);
SELECT T1.ListPrice - T1.StandardCost, T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ReviewerName = 'John Smith' ORDER BY T2.Rating DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
How much would be the total sales profit for shopping cart ID 20621 ?
Sales profit = MULTIPLY(SUBTRACT(ListPrice, StandardCost; Quantity)), where ShoppingCartID = '20621'
SELECT SUM((T1.ListPrice - T1.StandardCost) * T2.Quantity) FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 20621
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
What is the position of the employee with the 10th highest salary? Indicate his/her salary amount and his/her full name.
salary and Rate are synonyms; full name = FirstName+MiddleName+LastName;
SELECT T2.JobTitle, T1.Rate, T3.FirstName, T3.MiddleName, T3.LastName FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID ORDER BY T1.Rate DESC LIMIT 9, 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
How many transactions are there for product under the Mountain line?
The Mountain line refers to the product line, therefore ProductLine = 'M'
SELECT COUNT(T2.TransactionID) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'M'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
In episode nominated in Annie Awards, how many of the episodes have a percent greater than 6?
nominated refers to result = 'Nominee'; Annie Awards refers to organization = 'Annie Awards'; percent greater than 6 refers to percent > 6
SELECT COUNT(*) FROM Award AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.organization = 'Annie Awards' AND T1.result = 'Nominee' AND T2.percent > 6;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Please indicate total order quantity of product Candles and calculate the percentage of such product among all the orders.
total order quantity refers to Sum (Order Quantity); 'Candles' is the Products Name; percentage = Divide (Sum(Order Quantity where Product Name = 'Candles'), Sum(Order Quantity)) * 100
SELECT SUM(CASE WHEN T1.`Product Name` = 'Candles' THEN T2.`Order Quantity` ELSE 0 END), CAST(SUM(CASE WHEN T1.`Product Name` = 'Candles' THEN T2.`Order Quantity` ELSE 0 END) AS REAL) * 100 / SUM(T2.`Order Quantity`) FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store L...
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
For the order has the most product ordered, name the customer who placed the order.
The largest order in terms of total price refers to MAX(SUM(MULTIPLY(quantityOrdered, priceEach)).
SELECT T2.firstName, T2.lastName FROM offices AS T1 INNER JOIN employees AS T2 ON T1.officeCode = T2.officeCode WHERE T2.employeeNumber = ( SELECT MAX(employeeNumber) FROM employees )
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
Who made the purchase order with the greatest total due before freight? Indicate her employee ID and calculate for his/her age when he/she was hired.
total due before freight = SUBTRACT(TotalDue, Freight); age at the time an employee was hired = SUBTRACT(HireDate, year(BirthDate);
SELECT T2.BusinessEntityID, STRFTIME('%Y', T2.HireDate) - STRFTIME('%Y', T2.BirthDate) FROM PurchaseOrderHeader AS T1 INNER JOIN Employee AS T2 ON T1.EmployeeID = T2.BusinessEntityID ORDER BY T1.TotalDue DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Which is a high quality product but with the lowest transacted quantity?
High quality refers to the product's quality class, therefore Class = 'H'; the lowest transacted quantity refers to Quantity = 1
SELECT T1.Name FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Class = 'H' ORDER BY T2.Quantity ASC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
regional_sales
What is the store id of the store located in the most populous county?
most populous country refers to Max(Population)
SELECT CASE WHEN MAX(Population) THEN StoreID END FROM `Store Locations`
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
List all customer names with orders that are disputed.
Orders that are disputed refer to status = 'Disputed'; the sales representative means employees; names refers to firstName, lastName.
SELECT t3.firstName, t3.lastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber INNER JOIN employees AS t3 ON t2.salesRepEmployeeNumber = t3.employeeNumber WHERE t1.status = 'Disputed'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the total amount due of all the purchases made by the company to the vendor that has the lowest selling price amount of a single product? Indicate the name of the vendor to which the purchases was made.
Vendor's selling price of a single product refers to UnitPrice;
SELECT T1.UnitPrice, T3.Name FROM PurchaseOrderDetail AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID INNER JOIN Vendor AS T3 ON T2.VendorID = T3.BusinessEntityID ORDER BY T1.UnitPrice LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Provide all the transactions whereby the quantiy is more than 10,000 pieces. State the product name and the selling price.
Quantity more than 10,000 pieces refers to Quantity>10000; selling price refers to ListPrice
SELECT DISTINCT T1.Name, T1.ListPrice FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 10000
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List down the episode ID of episodes aired in 2008 with 5 stars and below.
aired in 2008 refers to air_date LIKE '2008%'; 5 stars and below refers to stars < 5
SELECT DISTINCT T1.episode_id FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE SUBSTR(T1.air_date, 1, 4) = '2008' AND T2.stars < 5;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many online orders were shipped during the month of June 2018?
online orders refers to Sales Channel = 'Online'; shipped during the month of June 2018 refers to SUBSTR(ShipDate, 1, 1) = '6' AND SUBSTR(ShipDate,-2) = '18'
SELECT SUM(IIF(ShipDate LIKE '6/%/18' AND `Sales Channel` = 'Online', 1, 0)) FROM `Sales Orders`
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
What is the total price of the order 10100?
SUM(MULTIPLY(quantityOrdered, priceEach)
SELECT SUM(t.priceEach * t.quantityOrdered) FROM orderdetails t WHERE t.orderNumber = '10100'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the age of the oldest Marketing Specialist by 12/31/2015 and what is his/her hourly rate?
age as of 12/31/2015 = SUBTRACT(2015, year(BirthDate)); hourly rate refers to Rate;
SELECT 2015 - STRFTIME('%Y', T1.BirthDate), T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Marketing Specialist' ORDER BY 2015 - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
For all the purchase order transactions, name all the products with low quality.
Low quality refers to the product's quality class, therefore Class = 'L'
SELECT DISTINCT T1.Name FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Class = 'L' AND T2.TransactionType = 'P' ORDER BY T1.Name
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
car_retails
What is the percentage of the payment amount in 2004 was made by Atelier graphique?
DIVIDE(SUM(amount) where customerName = 'Atelier graphique'), (SUM(amount)) as percentage where year(paymentDate) = 2004;
SELECT SUM(CASE WHEN t1.customerName = 'Atelier graphique' THEN t2.amount ELSE 0 END) * 100 / SUM(t2.amount) FROM customers AS t1 INNER JOIN payments AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t2.paymentDate) = '2004'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
To which group does the department with the least amount of workers belong to? Indicate the name of the department as well.
least amount of workers refers to MIN(count(DepartmentID));
SELECT T2.GroupName FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID GROUP BY T2.GroupName ORDER BY COUNT(T1.BusinessEntityID) LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
List the product name with more than 5 quantity in the shopping cart.
Product with more than 5 quantity refers to Quantity>5
SELECT T1.Name FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 5
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List the episode ID and title of episode where casting was credited to Bonita Pietila.
was credited refers to credited = 'true'; to Bonita Pietila refers to person = 'Bonita Pietila'
SELECT T1.episode_id, T1.title FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.credited = 'true' AND T2.person = 'Bonita Pietila' AND T2.role = 'casting';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
Between 2018 to 2020, what is the average amount of shipped orders per year under Carl Nguyen?
shipped refers to ShipDate; between 2018 and 2020 refers to SUBSTR(ShipDate, -2) IN ('18', '19', '20'); 'Carl Nguyen' is the name of Sales Team; average shipped orders per year = Divide (Count(OrderNumber), 3)
SELECT CAST(COUNT(T1.OrderNumber) AS REAL) / 3 FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/18') OR (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/19') OR (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate L...
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
Name the Sales Manager of Europe, Middle East, and Africa region. In which office does he/she report to?
Sales Manager refers to jobTitle; Europe, Middle East, and Africa region refers to territory = 'EMEA';
SELECT t2.firstName, t2.lastName FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode WHERE t2.jobTitle = 'Sale Manager (EMEA)'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
works_cycles
What is the average age of the sales agents in the company by 12/31/2009?
average age as of 12/31/2009 = AVG(SUBTRACT(2009, year(BirthDate));
SELECT AVG(2009 - STRFTIME('%Y', T2.BirthDate)) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SP'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...