db_id
stringclasses
69 values
schema
stringclasses
69 values
m_schema
stringclasses
69 values
question
stringlengths
24
325
sql
stringlengths
23
804
evidence
stringlengths
0
673
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
For all the products, list the product name and its corresponding start date for the current standard cost.
SELECT T1.Name, T2.StartDate FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.EndDate IS NULL
The current standard cost refers to EndDate is NULL
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List the products whereby the standard cost is $80 more than previous standard cost in history.
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.StandardCost - T2.StandardCost > 80 GROUP BY T1.Name
SUBTRACT(product.StandardCost, CostHistory.StandardCost)>80
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Name all products and total quantity for each item for shopping cart ID 14951.
SELECT T1.Name, T2.Quantity FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 14951
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List the product name with more than 5 quantity in the shopping cart.
SELECT T1.Name FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 5
Product with more than 5 quantity refers to Quantity>5
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
For all the purchase order transactions, name all the products with low quality.
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
Low quality refers to the product's quality class, therefore Class = 'L'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Provide all the transactions whereby the quantiy is more than 10,000 pieces. State the product name and the selling price.
SELECT DISTINCT T1.Name, T1.ListPrice FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 10000
Quantity more than 10,000 pieces refers to Quantity>10000; selling price refers to ListPrice
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which is a high quality product but with the lowest transacted quantity?
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
High quality refers to the product's quality class, therefore Class = 'H'; the lowest transacted quantity refers to Quantity = 1
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many transactions are there for product under the Mountain line?
SELECT COUNT(T2.TransactionID) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'M'
The Mountain line refers to the product line, therefore ProductLine = 'M'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How much would be the total sales profit for shopping cart ID 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
Sales profit = MULTIPLY(SUBTRACT(ListPrice, StandardCost; Quantity)), where ShoppingCartID = '20621'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List all product names that are high in quality. Please also state its selling price.
SELECT Name, ListPrice FROM Product WHERE Class = 'H'
High quality refers to the product's quality class, therefore Class = 'H'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which product line has the most products that are salable?
SELECT ProductLine FROM Product WHERE FinishedGoodsFlag = 1 GROUP BY ProductLine ORDER BY COUNT(FinishedGoodsFlag) DESC LIMIT 1
Saleable product refers to FinishedGoodsFlag = 1
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Provide details of review from reviewer whose name begin with letter 'J'. State the product ID, rating and comments.
SELECT ProductID, Rating, Comments FROM ProductReview WHERE ReviewerName LIKE 'J%'
reviewer whose name begin with letter 'J' = ReviewerName LIKE 'J%'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
State the product name, product line, rating and the selling price of product with the lowest rating.
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
Product with the lowest rating refers to the rating given by the reviewer where Rating = 1
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Calculate the profit of each products. List all products with more than $100 in profit.
SELECT DISTINCT Name FROM Product WHERE ListPrice - StandardCost > 100
Profit = AVG(SUBTRACT(ListPrice, StandardCost)>100
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List down the product name, reviewer name, rating and comments for product under the road line.
SELECT T1.Name, T2.ReviewerName, T2.Rating, T2.Comments FROM Product AS T1 INNER JOIN ProductReview AS T2 USING (productID) WHERE T1.ProductLine = 'R'
The Road line refers to the product line, therefore ProductLine = 'R'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many people reviewed for product named HL Mountain Pedal? What is the average rating?
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'
AVG(Rating) = DIVIDE(SUM(rating), COUNT(ReviewerName))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List the purchase order whereby all received quantity were rejected? Name those product.
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
Rejected refers rejected product in which to RejectedQty = 1
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among all products without any rejected quantity, which product has the highest line total? State the product name and unit price.
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
Product without any rejected quantity refers to RejectedQty = 0
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List all product names and its product line for all purchase order with order quantity of 5000 or more.
SELECT T1.Name, T1.ProductLine FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderQty > 4999
Purchase order with order quantity of 5000 or more refers to OrderQty> = 5000
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the total ordered quantity for products under the 'Touring' line?
SELECT SUM(T2.OrderQty) FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'T'
The Touring line refers to the product line, therefore ProductLine = 'T'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the low quality product, which product has the highest line total? List the product name and its line total?
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
Low quality refers to the product's quality class, therefore Class = 'L'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which product has the highest profit on net? State the product name.
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
Profit on net = SUBTRACT(LastReceiptCost, StandardPrice)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List all products with minimum order quantity of 100 and order them by product name in descending order.
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
miinimum order quantity refers to MinOrderQty = 100
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List the name and calculate its profit for product with the highest rating in review.
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
Profit = SUBTRACT(ListPrice, StandardCost); the highest rating in review refers to Rating = 5
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the total profit all transactions with product ID 827?
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
Profit = MULTIPLY(SUBTRACT(ListPrice, StandardCost) Quantity))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which currency pair's average exchange rate for the day is the highest?
SELECT FromCurrencyCode, ToCurrencyCode FROM CurrencyRate ORDER BY AverageRate DESC LIMIT 1
currency pair refers to FromCurrencyCode/ToCurrencyCode
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many products with the highest unit price were ordered?
SELECT OrderQty FROM PurchaseOrderDetail ORDER BY UnitPrice DESC LIMIT 1
number of products refers to OrderQty
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Between Northwest and Southeast of the United States, which territory one recorded the highest amount of sales last year?
SELECT Name FROM SalesTerritory WHERE CountryRegionCode = 'US' AND (Name = 'Northwest' OR Name = 'Southeast') ORDER BY SalesLastYear DESC LIMIT 1
United States refers to CountryRegionCode = 'US';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the full name of the Document Control Manager who is in charge of all Level 1 approved documents?
SELECT T1.FirstName, T1.MiddleName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Document AS T3 ON T3.Owner = T2.BusinessEntityID WHERE T2.JobTitle = 'Document Control Manager' AND T3.DocumentLevel = 1 AND T3.Status = 2 GROUP BY T1.FirstName, T1.MiddleN...
full Name = FirstName+MiddleName+Last Name; approved document refers to Status = 2;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which customer has the highest subtotal amount of sales orders whose assigned to the salesperson with the highest bonus?
SELECT T1.CustomerID FROM SalesOrderHeader AS T1 INNER JOIN SalesPerson AS T2 ON T1.SalesPersonID = T2.BusinessEntityID ORDER BY T1.SubTotal DESC LIMIT 1
highest subtotal amount of sales order refers to max(SubTotal);
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the total price of Sales Order ID 46625 with Volume Discount 11 to 14 and Product ID 716?
SELECT T2.UnitPrice * T2.OrderQty FROM SpecialOffer AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID WHERE T1.Description = 'Volume Discount 11 to 14' AND T1.SpecialOfferID = 2 AND T2.ProductID = 716 AND T2.SalesOrderID = 46625
total price = multiply(UnitPrice, OrderQty);
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Of the products that has a reorder inventory point of no more than 600, how many manufactured in-house products that takes 1 day to manufacture with BOM Level 4 are there?
SELECT COUNT(T1.ProductID) FROM Product AS T1 INNER JOIN BillOfMaterials AS T2 ON T1.ProductID = T2.ProductAssemblyID WHERE T1.MakeFlag = 1 AND T1.DaysToManufacture = 1 AND T2.BOMLevel = 4 AND T1.ReorderPoint <= 600
ReorderPoint<600; product is manufactured in-house refers to Makeflag = 1;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the highest amount of bonus earned by the sales person in Canada?
SELECT T2.Bonus FROM SalesTerritory AS T1 INNER JOIN SalesPerson AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.CountryRegionCode = 'CA' ORDER BY T2.SalesQuota DESC LIMIT 1
Canada is name of a sales territory
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What are the names of the product that has the lowest rating?
SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating ASC LIMIT 1 )
lowest rating refers to Rating = 1;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many of the workers who started working in 2009 are from the Production Department?
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.StartDate >= '2009-01-01' AND T2.StartDate < '2010-01-01' AND T1.Name = 'Production'
StartDate BETWEEN '2009-01-01' AND '2009-12-31';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Who is the company's highest-paid single female employee? Include her full name and job title.
SELECT T3.FirstName, T3.MiddleName, T3.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'F' ORDER BY T2.Rate DESC LIMIT 1
full name = FirstName+MiddleName+LastName; highest-paid refers to max(Rate); single refers to Status = 'S'; female refers to Gender = 'F';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Who is the Vice President of Engineering and when did he join the company? Indicate his/her full name.
SELECT T2.FirstName, T2.MiddleName, T2.LastName, T1.HireDate FROM Employee AS T1 INNER JOIN Person AS T2 USING (BusinessEntityID) WHERE T1.JobTitle = 'Vice President of Engineering'
full name = FirstName+MiddleName+LastName; HiredDate refers to the date the person joins the company;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many active employees whose payrate is equal or below 30 per hour.
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.Rate <= 30
active employee refers to CurrentFlag = 1; Rate< = 30;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which department has a worker who just recently started working?
SELECT T1.Name FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID ORDER BY T2.StartDate DESC LIMIT 1
recently started working refers to latest StartDate;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which store sales person was reently hired? Indicate his/her full name and gender.
SELECT T2.FirstName, T2.MiddleName, T2.LastName, T1.Gender FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP'
SC is an abbreviation for Store Contact; store contact person refers to PersonType = 'SC'; recently hired refers to latest StartDate;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How frequently do the employee with the least number of sick leave hours get paid?
SELECT T2.PayFrequency FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.SickLeaveHours ASC LIMIT 1
least number of sick leave refers to min(SickLeaveHours); PayFrequency = 1 means ‘Salary received monthly’; PayFrequency = 2 means ‘Salary received biweekly';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Which job title has the lowest pay?
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.Rate ASC LIMIT 1
lowest pay refers to min(Rate);
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the total number of employees that worked in the Finance department?
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (DepartmentID) WHERE T1.Name = 'Finance'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the profit of the product with the highest list price and of the product with the lowest list price other than 0? Indicates the depth the component is from its parent.
SELECT ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice DESC LIMIT 1 ) , ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice LIMIT 1 )
profit = subtract(ListPrice, StandardCost); the depth the component from its parent refers to BOMLevel;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the companies to which Adventure Works Cycles purchases parts or other goods, what is the profit on net obtained from the vendor who has an above average credit rating? Kindly indicate each names of the vendor and the corresponding net profits.
SELECT T2.Name, T1.LastReceiptCost - T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CreditRating = 3
above average credit rating refers to CreditRating = 3; profit on net = subtract(LastReceiptCost, StandardPrice);
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many accounts have an address that is too long?
SELECT COUNT(*) FROM Address WHERE AddressLine2 <> ''
address that is too long refers to AddressLine2! = null
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the postal code of the street address of the account that is latest updated?
SELECT PostalCode FROM Address ORDER BY ModifiedDate DESC LIMIT 1
account latest updated refers to year(ModifiedDate) = 2022 and month(ModifiedDate) = 10
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the longest assembly item duration for bicycles?
SELECT JULIANDAY(EndDate) - JULIANDAY(StartDate) FROM BillOfMaterials ORDER BY JULIANDAY(EndDate) - JULIANDAY(StartDate) DESC LIMIT 1
longest assembly item duration = max(subtract(EndDate,StartDate))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many assembly items for bicycles aren't finished?
SELECT COUNT(BillOfMaterialsID) FROM BillOfMaterials WHERE EndDate IS NULL
assembly lines that are not finished refers to EndDate = null
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please list the unit measure code of the component that is of the greatest need in quantity to create the assembly.
SELECT UnitMeasureCode FROM BillOfMaterials ORDER BY PerAssemblyQty DESC LIMIT 1
greatest need in quantity refers to max(PerAssemblyQty)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many product maintenance documents are private?
SELECT COUNT(DocumentNode) FROM Document WHERE DocumentSummary IS NULL
product maintenance documents are private refers to DocumentSummary = null
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please list the titles of the documents that are pending approval.
SELECT Title FROM Document WHERE Status = 1
documents pending approval refers to Status = 1
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please list the job titles of the employees who has a document that has been approved.
SELECT DISTINCT T2.BusinessEntityID, T2.JobTitle FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 2
document has been approved refers to Status = 2
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the pay frequency of the oldest employee?
SELECT T1.PayFrequency FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.BirthDate ASC LIMIT 1
oldest employee refers to min(BirthDate); PayFrequency = 1 refers to ‘Salary received monthly’; PayFrequency = 2 refers to ‘Salary received biweekly'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the employees whose pay frequencies are the highest, how many of them are married?
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T1.PayFrequency = ( SELECT PayFrequency FROM EmployeePayHistory ORDER BY PayFrequency DESC LIMIT 1 )
married refers to MaritalStatus = M; highest pay frequency refers to PayFrequency = 2
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
For the employee who has been hired the latest, what is his or her pay rate?
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.HireDate DESC LIMIT 1
hired the latest refers to max(HireDate)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the employees who have a pay rate of above 40, how many of them are male?
SELECT SUM(CASE WHEN T2.Gender = 'M' THEN 1 ELSE 0 END) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate > 40
pay rate above 40 refers to Rate>40; male employee refers to Gender = M
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the highest pay rate of the employees who are exempt from collective bargaining?
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SalariedFlag = 1 ORDER BY T1.Rate DESC LIMIT 1
employee exempt from collective bargaining refers to SalariedFlag = 1; highest pay rate refers to max(Rate)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
For the employees who have the highest pay frequency, please list their vacation hours.
SELECT T2.VacationHours FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.BusinessEntityID = ( SELECT BusinessEntityID FROM EmployeePayHistory ORDER BY Rate DESC LIMIT 1 )
highest pay frequency refers to PayFrequency = 2
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the pay rate of the employee who has the longest vacation hours?
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.VacationHours DESC LIMIT 1
longest vacation hour refers to max(VacationHours)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many employees with a pay rate of over 35 have more than 10 sick leave hours?
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SickLeaveHours > 10 AND T1.Rate > 35
more than 10 sick leave hours refers to SickLeaveHours>10; pay rate over 35 refers to Rate>35;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the active male employees, how many of them are paid with the highest frequency?
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.Gender = 'M' AND T1.PayFrequency = 2
active status of employees refers to CurrentFlag = 1; Male refers to Gender = 'M'; highest frequency refers to PayFrequency = 2;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many male employees have the job position of sales person?
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T2.PersonType = 'SP'
Sales person refers to PersonType = 'SP'; Male refers to Gender = 'M';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the job position of the oldest employee?
SELECT T2.PersonType FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.BirthDate ASC LIMIT 1
Oldest employee refers to Max ( Subtract((now())-BirthDate));
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the name style of the employee with the lowest pay rate?
SELECT T2.NameStyle FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate IS NOT NULL ORDER BY T1.Rate ASC LIMIT 1
lowest pay rate refers to Min(Rate);
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the employees who are married, how many of them have a western name style?
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.MaritalStatus = 'M'
married refers to MaritalStatus = 'M'; western name style refers to NameStyle = '0';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the employees who have more than 10 hours of sick leave, how many of them wish to receive e-mail promotions?
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.SickLeaveHours > 10
Contact does wish to receive e-mail promotions refers to EmailPromotion = (1,2); more than 10 hours of sick leave refer to SickLeaveHours >10;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please list the employees who have more than 20 vacations hours and wish to receive e-mail promotions.
SELECT T1.BusinessEntityID FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.VacationHours > 20
Contact does wish to receive e-mail promotions refers to EmailPromotion = (1,2); more than 20 vacations hours refers to VacationHours>20
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please give the additional contact information of the oldest employee with the jod position of sales person.
SELECT T2.AdditionalContactInfo FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE PersonType = 'SP' ORDER BY T1.BirthDate ASC LIMIT 1
Sales person refers to PersonType = 'SP'; oldest employee refers to Max (Subtract((now())-BirthDate));
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the first name of the male employee who has a western name style?
SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.Gender = 'M'
western name style refers to NameStyle = 0; Male refers to Gender = 'M';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the active employees, how many of them have a courtesy title of "Mr"?
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.Title = 'Mr.'
active status of employees refers to CurrentFlag = 1;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please give the personal information of the married employee who has the highest pay rate.
SELECT T2.Demographics FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' ORDER BY T3.Rate DESC LIMIT 1
married refers to MaritalStatus = 'M'; Highest pay rate refers to Max(Rate)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the surname suffix of the employee who works as a store contact and has the longest sick leave hours?
SELECT T2.Suffix FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP' ORDER BY T1.SickLeaveHours DESC LIMIT 1
store contact refers to PersonType = 'SC';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the married employees with the highest pay frequency, how many of them have an eastern name style?
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' AND T2.NameStyle = 1 AND T3.Rate = ( SELECT Rate FROM EmployeePayHistory ORDER BY Rate ...
married refers to MaritalStatus = 'M'; Eastern name style refers to NameStyle = 1;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many active employees do not wish to receive e-mail promotions?
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.EmailPromotion = 1
active status of employees refers to CurrentFlag = 1; the employee does not wish to receive an e-mail promotion refers to EmailPromotion = 0;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Please list the credit card IDs of the employees who work as store contact.
SELECT T2.CreditCardID FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SC'
store contact refers to PersonType = 'SC';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many vacation hours do the male employees have on average?
SELECT CAST(SUM(T1.VacationHours) AS REAL) / COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T2.PersonType = 'EM'
employee refers to PersonType = 'EM'; Male refers to Gender = 'M'; Average = Divide( SUM(VacationHours(PersonType = 'EM'& Gender = 'M')),Count(BusinessEntityID(PersonType = 'EM' & Gender = 'M')));
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the employees who are married and wish to receive e-mail promotions, how much higher is their highest pay rate from the average pay rate?
SELECT MAX(T1.Rate) - SUM(T1.Rate) / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T2.EmailPromotion = 2 AND T3.MaritalStatus = 'M'
married refers to MaritalStatus = 'M'; Contact does wish to receive e-mail promotions from Adventure Works refers to EmailPromotion = 1; Average = Divide (Sum(Rate (MaritalStatus = 'M' & EmailPromotion = 1))), Count (BusinessEntityID (MaritalStatus = 'M' & EmailPromotion = 1)); MAX(Rate (MaritalStatus = 'M' & EmailProm...
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
If a married employee has a western name style, what is the probability of him or her working as a store contact?
SELECT CAST(COUNT(IIF(T1.PersonType = 'SC', T1.PersonType, NULL)) AS REAL) / COUNT(T1.PersonType) FROM Person AS T1 INNER JOIN Employee AS T2 WHERE T1.PersonType = 'SC' AND T1.NameStyle = 0 AND T2.MaritalStatus = 'M'
married refers to MaritalStatus = 'M'; western name style refers to NameStyle = 0; store contact refers to PersonType = 'SC'; probability = Divide (Count (BusinessEntityID( PersonType = 'SC' & MaritalStatus = 'M')), Count (BusinessEntityID ( PersonType) & MariatlStatus = 'M'))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Among the active employees with over 10 hours of sick leave, what is the percentage of the employees with over 20 vacation hours?
SELECT CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10
CurrentFlag = 1 refers to the active status of employees; Percentage = Divide (Count (BusinessEntityID (CurrentFlag = 1 & VacationHours >20 & SickLeaveHours > 10)), Count (BusinessEntityID (CurrentFlag = 1 & SickLeaveHours>10))) * 100;
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Average of the last receipt cost of the products whose average lead time is 60 days.
SELECT SUM(LastReceiptCost) / COUNT(ProductID) FROM ProductVendor WHERE AverageLeadTime = 60
average = DIVIDE(SUM(lastreceiptcost), COUNT(OnorderQty)) where AverageLeadTime = 60
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Average cost of purchase orders made during the first six months of 2012.
SELECT CAST(SUM(ActualCost) AS REAL) / COUNT(TransactionID) FROM TransactionHistoryArchive WHERE TransactionType = 'P' AND TransactionDate >= '2012-01-01' AND TransactionDate < '2012-07-01'
purchase orders refers to TransactionType = 'P'; first six months of 2012 refers to TransactionDate bewteen '2012-01-01'and '2012-06-30'; average = DIVIDE(ActualCost where TransactionType = 'P', count(TransactionID))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What percentage of male employees hired throughout the years 2009 are married?
SELECT CAST(SUM(CASE WHEN MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee WHERE SUBSTR(HireDate, 1, 4) = '2009' AND Gender = 'M'
male refers to Gender = 'M'; hired throughout the years 2009 refers to Year(HireDate) = 2009; married refers to MaritalStatus = 'M'; percentage = DIVIDE(count(BusinessEntityID(Gender = 'M'& Year(HireDate) = '2009& MaritalStatus = 'M')), count(BusinessEntityID(Gender = 'M'& Year(HireDate) = 2009)))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What percentage of people named Mary who wants Receive Email promotions of AdventureWorks and selected partners are store contacts?
SELECT CAST(SUM(CASE WHEN EmailPromotion = 2 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN PersonType = 'SC' THEN 1 ELSE 0 END) FROM Person WHERE FirstName = 'Mary'
wants Receive Email promotions of AdventureWorks and selected partners refers to EmailPromotion = 2; store contact refers to PersonType = 'SC'; percentage = DIVIDE(count(BusinessEntityID(FirstName = 'Marry'&EmailPromotion = '2')),count(BusinessEntityID)))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List, by ProductID, all products whose profit, relative to the standard price, is negative.
SELECT DISTINCT ProductID FROM ProductVendor WHERE StandardPrice - LastReceiptCost < 0
Profit = SUBTRACT(StandardPrice, LastRecipeCost)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the average total due price of products with approved status?
SELECT SUM(TotalDue) / COUNT(TotalDue) FROM PurchaseOrderHeader WHERE Status = 2
approved refers to Status = 2 , average total due price = AVG( DIVIDE(TotalDue, SUM(Status = 2 )))
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the percentage, by number of sales order units, for orders with quantities not greater than 3 and a discount of 0.2?
SELECT CAST(SUM(CASE WHEN OrderQty < 3 AND UnitPriceDiscount = 0.2 THEN 1 ELSE 0 END) AS REAL) / COUNT(SalesOrderID) FROM SalesOrderDetail
quantities not greater than 3 refers to OrderQty<3; discount of 0.2 refers to UnitPriceDiscount = 0.2; percentage = DIVIDE(count(SalesOrderID(OrderQty<3 & UnitPriceDiscount = 0.2)), count(SalesOrderID))*100%
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Lists all companies by BusinessEntityID that increased their current year sales by more than 60% over last year's sales and have a bonus greater than 3,000.
SELECT BusinessEntityID FROM SalesPerson WHERE SalesYTD > SalesLastYear + SalesLastyear * 0.6 AND Bonus > 3000
increased their current year sales by more than 60% refers to DIVIDE(SUBTRACT(SalesYTD, SalesLastYear),SalesLastYear)>0.6
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Add the number of businesses that indicate their home address as their address and those whose address corresponds to the shipping address.
SELECT SUM(CASE WHEN T2.Name = 'Home' THEN 1 ELSE 0 END) , SUM(CASE WHEN T2.Name = 'Shipping' THEN 1 ELSE 0 END) FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID
their home address as their address refers to AddressTypeID = 2; address corresponds to the shipping address refers to AddressTypeID = 5
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Identifies the ID number of the customer whose sales order for 32 units had a unit price of 35.
SELECT T2.CustomerID FROM SalesOrderDetail AS T1 INNER JOIN Customer AS T2 WHERE T1.UnitPrice = 35 AND T1.OrderQty = 32
sales order for 32 units refers to OrderQty = 32
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What company has a Colonial Voice card that expired in March 2005?
SELECT T2.BusinessEntityID FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.CardType = 'ColonialVoice' AND T1.ExpMonth = 3 AND T1.ExpYear = 2005
Colonial Voice card refers to CardType = 'ColonialVoice' ; expired in March 2005 refers to ExpMonth = 3, ExpYear = 2005
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the credit rating of the company whose average lead time is 16 days for a standard price of 18.9900 and whose last receipt date is August 27, 2011?
SELECT T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.StandardPrice = 18.9900 AND T1.AverageLeadTime = 16 AND STRFTIME('%Y-%m-%d', T1.LastReceiptDate) = '2011-08-27'
last receipt date is August 17, 2011 refers to LastReceiptDate> = '2011-08-17 00:00:00' and LastReceiptDate < '2011-08-18 00:00:00';
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Calculate the number of products if we add the products of the accessories and components categories.
SELECT COUNT(ProductID) FROM Product WHERE Name LIKE '%accessories %' OR Name LIKE '%components%'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What is the job title of the newest employee in department 12?
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.DepartmentID = 12 ORDER BY T2.StartDate DESC LIMIT 1
newest employee refers to MAX(StartDate)
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
List the first and last name of all unmarried male Production Supervisors.
SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'M' AND T1.JobTitle LIKE 'Production Supervisor%'
unmarried refers to MaritalStatus = 'S', male refers to Gender = 'M', Production Supervisors is a job title
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
How many products are there if we add all those located in the Subassembly category?
SELECT COUNT(T1.LocationID) FROM Location AS T1 INNER JOIN ProductInventory AS T2 USING (LocationID) WHERE T1.Name = 'Subassembly'
located in the Subassembly category refers to Name = 'Subassembly'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Sum the total number of products rejected for having a trim length that is too long.
SELECT SUM(T2.ScrappedQty) FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Trim length too long'
number of product rejected refers to ScrapedQty; trim length that is too long refers to scrap reason where Name = 'Trim length too long'
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
Calculate the total quantity of purchased product that has been prepared by employee number 257 and is in pending shipment status.
SELECT SUM(T2.OrderQty) FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID WHERE T1.Status = 1
employee number 257 refers to EmployeeID = 257; pending shipment status refers to Status = 3
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
If we discount the products that do not have any type of offer, how many different products have been sold in an amount greater than 2 units per order?
SELECT COUNT(DISTINCT T1.ProductID) FROM SalesOrderDetail AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN SpecialOffer AS T3 ON T2.SpecialOfferID = T3.SpecialOfferID WHERE T1.OrderQty > 2 AND T1.UnitPriceDiscount = 0
do not have any type of offer refers to Description = 'No Discount'; sold in an amount greater than 2 refers to OrderQty>2
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
【DB_ID】 works_cycles 【Schema】 # Table: main.Address [ (AddressID:INTEGER, Primary Key, Examples: [18089, 23192, 25702]), (AddressLine1:TEXT, Examples: [#500-75 O'Connor Street]), (AddressLine2:TEXT, Examples: [Space 55, Unit B-105, #3]), (City:TEXT, Examples: [Ottawa, Burnaby, Dunkerque]), (StateProvinceID:INTEGER, Exa...
What type of transaction was made with the only yellow product, size 62 and with a minimum inventory stock of 500 units?
SELECT DISTINCT T2.TransactionType FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Size = 62 AND T1.Color = 'Yellow' AND T1.SafetyStockLevel = 500
yellow product refers to Color = 'Yellow'; minimum inventory stock of 500 units refers to SafetyStockLevel = 500