db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
works_cycles
What is the primary type of all single female employees hired between 1/1/2008 to 12/31/2008?
primary type refers to PersonType; single refers to MaritalStatus = 'S"; female refers to Gender = 'F'; HireDate BETWEEN '2010-1-1'AND '2010-12-31';
SELECT T2.PersonType FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F' AND T1.MaritalStatus = 'S' AND STRFTIME('%Y-%m-%d', T1.HireDate) BETWEEN '2008-1-1' AND '2008-12-31' GROUP BY T2.PersonType ORDER BY COUNT(T2.PersonType) 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
Of the employees whose vacation hours are no more than 10, what is the age of the oldest employee at the time he/she was hired? Indicate his/her full name.
VacationHours<10; age at the time of being hired = SUBTRACT(year(HireDate), year(BirthDate)); full name = FirstName+MiddleName+LastName;
SELECT STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate), T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.VacationHours <= 10 ORDER BY STRFTIME('%Y', T1.HireDate) - 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
How much are the minimum orders of the vendors that are no longer used by the company?
vendors that are no longer used by the company refers to ActiveFlag = 0;
SELECT T2.MinOrderQty FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ActiveFlag = 0 ORDER BY T2.MinOrderQty 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
What are the names of the vendor with the second lowest minimum order quantity?
minimum order quantity refers to MinOrderQty;
SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.MaxOrderQty ASC 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 full name of the non-sales employee who made the most number of rejected purchase orders?
non-sales employee refers to PersonType = 'EM'; rejected purchase order refers to Status = 3;
SELECT T2.FirstName, T2.LastName FROM PurchaseOrderHeader AS T1 INNER JOIN Person AS T2 ON T1.EmployeeID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' AND T1.Status = 3 GROUP BY T2.FirstName, T2.LastName ORDER BY COUNT(T1.PurchaseOrderID) 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
What is the profit on net of the products that have exactly 200 maximum order quantity? Indicate the name of the vendors to which these products were purchased from.
maximum orders refers to MaxOrderQty; MaxOrderQty = 200; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);
SELECT T1.LastReceiptCost - T1.StandardPrice, T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty = 200
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 products with an average lead time of 60, which vendor has the highest profit on net? Indicate the credit rating of such vendor.
profit on net = SUBTRACT(LastReceiptCost, StandardPrice);
SELECT T2.Name, T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.AverageLeadTime = 60 ORDER BY T1.LastReceiptCost - T1.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...
works_cycles
What are the full names of the 10 youngest married male production technicians?
youngest refers to latest BirthDate; married refers to MaritalStatus = 'M'; production technician is a JobTitle; 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 WHERE T1.JobTitle LIKE 'Production Technician%' AND T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate DESC LIMIT 10
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 profit can the company gained from selling two high class black Road Bikes with a size of 58?
high class refers to Class = 'H"; road bikes is a name of product subcategory; profit = (MULTIPLY(SUBTRACT(ListPrice, StandardCost)), (2)));
SELECT 2 * (T1.ListPrice - T1.StandardCost) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID WHERE T1.Class = 'H' AND T1.Color = 'Black' AND T1.Size = 58 AND T2.Name = 'Road Bikes'
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 department has the most number of night shifts?
most number of night shift = MAX(count(shift.Name = 'Night'))
SELECT T3.Name FROM Shift AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.ShiftId = T2.ShiftId INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID GROUP BY T2.DepartmentID ORDER BY COUNT(T1.Name = 'Night') 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 vendors with an average credit rating, what is the overall total due amount of purchases made by the company to the vendor that isn't preferrerd if another vendor is available?
average credit rating refers to CreditRating = 4;  vendor that isn't preferrerd if another vendor is available refers to PreferredVendorStatus = 0; SUM(TotalDue);
SELECT SUM(T2.TotalDue) FROM Vendor AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.BusinessEntityID = T2.VendorID WHERE T1.CreditRating = 4 AND T1.PreferredVendorStatus = 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
When did the Senior Tool Designer, who was 33 years old at the time he was hired, stopped working in the Engineering department?
Senior Tool Designer is a JobTitle; 33 years old at the time of hiring refers to SUBTRACT(year(HireDate)), (year(BirthDate)) = 33;
SELECT T2.EndDate FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T1.JobTitle = 'Senior Tool Designer' AND STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) = 33 AND T2.EndDate IS ...
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 are the full names of the sales person whose bonuses are less than 1,000?
full name = FirstName+MiddleName+LastName; Bonus<1000;
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Bonus < 1000
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 allows the company to make the highest profit on a single item among those that are the fastest to manufacture? Indicate the rating of the product if there any.
profit on a single item = SUBTRACT(ListPrice, StandardCost); length of time to manufacture refers to DaysToManufacture; fastest to manucature refers to MIN(DaysToManufacture);
SELECT T1.Name, T2.Rating FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.DaysToManufacture = ( SELECT DaysToManufacture FROM Product ORDER BY DaysToManufacture LIMIT 1 ) ORDER BY T1.ListPrice - T1.StandardCost 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 employees who were born before 1969, what is the work shift of the 6th oldest employee?
oldest employee born before 1969 refers to year(BirthDate)<'1969';
SELECT T3.StartTime, T3.EndTime FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE STRFTIME('%Y', T1.BirthDate) < '1969' ORDER BY T1.BirthDate LIMIT 5, 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 person have a projected yearly sales of no more than 50,000?
projected yearly sales refers to SalesQuota; SalesQuota< = 50000;
SELECT COUNT(BusinessEntityID) FROM SalesPersonQuotaHistory WHERE SalesQuota < 500000
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 is the tax amount of the purchase order with the biggest tax amount? Indicate the purchase order ID.
tax amount refers to TaxAmt; biggest tax amount refers to MAX(TaxAmt);
SELECT TaxAmt, PurchaseOrderID FROM PurchaseOrderHeader ORDER BY TaxAmt 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
What profit will the company gain if they sell 10 items of the product that has the lightest weight?
Lightest product refers to Min(Weight); profit if they sell 10 items refers to Subtract (ListPrice , StandardCost) *10;
SELECT 10 * (ListPrice - StandardCost) FROM Product WHERE Weight IS NOT NULL ORDER BY Weight 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 is the amount to be paid by the company for the purchase order with the third highest freight amount?
amount to be paid refers to TotalDue;
SELECT TotalDue FROM PurchaseOrderHeader ORDER BY Freight DESC LIMIT 2, 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 are the names of the top 6 products that has the biggest size in centimeter and what are its reorder point?
in centimeter refers to SizeUnitMeasureCode = 'CM';
SELECT Name, ReorderPoint FROM Product WHERE SizeUnitMeasureCode = 'CM' ORDER BY Size DESC LIMIT 6
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 territory has the greatest difference in sales from previous year to this year? Indicate the difference, as well as the name and country of the region.
greatest difference in sales from previous year to this year refers to Max(Subtract(SalesLastYear,SalesYTD));
SELECT SalesLastYear - SalesYTD, Name, CountryRegionCode FROM SalesTerritory ORDER BY SalesLastYear - SalesYTD 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
What is the weight in pounds of the style that is produced the most by the company? If there are multiple products sharing the same weight, indicate the name of each one of them and their corresponding weights.
weight in pounds refers to WeightUnitMeasureCode = 'LB';
SELECT Weight FROM Product WHERE WeightUnitMeasureCode = 'LB' GROUP BY Weight ORDER BY COUNT(Style) 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
What time does the company's night shift begin? Indicate the answer in regular form.
Night shift refers to Name = 'Night';
SELECT StartTime FROM Shift WHERE Name = 'Night'
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 Vista cards expired before the year 2007?
Vista Card refers to CardType = 'Vista'; expire before the year 2007 refers to ExpYear< = 2006;
SELECT COUNT(CreditCardID) FROM CreditCard WHERE CardType = 'Vista' AND ExpYear < 2007
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 company's second highest salary per hour for employees who are paid monthly?
salary received monthly refers to PayFrequency = 1; highest salary per hour refers to Max(Rate);
SELECT Rate FROM EmployeePayHistory WHERE PayFrequency = 1 ORDER BY Rate 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 name of the product with the almost highest review score?
highest review score refers to Rating = 5;
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = ( SELECT Rating FROM ProductReview ORDER BY 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
What is the Crankarm product's net profit?
net profit = Subtract(LastReceiptCost, StandardPrice);
SELECT T2.LastReceiptCost - T2.StandardPrice FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE '%Crankarm%'
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 percentage of businesses in the Northwest US have forecasted annual sales of above 300,000?
Northwest refers to Name = 'Northwest'; US refers to CountryRegionCode = 'US'; forecasted annual sales of above 300,000 refers to SalesQuota >300000; Percentage = Divide(Count(TerritoryID(SalesQuota >300000)),Count(TerritoryID))*100
SELECT CAST(SUM(CASE WHEN T1.SalesQuota > 300000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T2.CountryRegionCode = 'US' AND T2.Name = 'Northwest'
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 difference in percentage between the product descriptions written in Arabic and Thai?
Arabic and Thai are language names refers to name = 'Arabic'and name = 'Thai'; Differencce in percentage = Subtract(((Count(CultureID(name = 'Arabic'))/Count(CultureID))*100),((Count(CultureID(name = 'Thai'))/Count(CultureID))*100)));
SELECT CAST(SUM(CASE WHEN T1.Name = 'Arabic' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID
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 name of the state that Racine belongs to?
Racine is a city
SELECT T2.Name FROM Address AS T1 INNER JOIN StateProvince AS T2 ON T1.StateProvinceID = T2.StateProvinceID WHERE T1.City = 'Racine'
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
Please list any three businesses with their IDs that are located in Dallas City.
business with ther ID refers to BusinessEntityID
SELECT T2.BusinessEntityID FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T1.City = 'Dallas' LIMIT 3
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 12th business's first line address?
12th business refers to BusinessEntityID = 12;
SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 12
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 order reference number for the "Mountain End Caps" product?
Order Reference Number refers to ReferenceOrderID
SELECT T2.ReferenceOrderID FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain End Caps'
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
Who is the "Next-Door Bike Store" point of contact?
Next-Door Bike Store is name of a store
SELECT T1.Name FROM ContactType AS T1 INNER JOIN BusinessEntityContact AS T2 ON T1.ContactTypeID = T2.ContactTypeID INNER JOIN Store AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.Name = 'Next-Door Bike Store'
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 address type does "Fun Toys and Bikes" fall under?
Fun Toys and Bikes is name of a store
SELECT T2.Name FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID INNER JOIN Store AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.Name = 'Fun Toys and Bikes'
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
Where are the shelves where the down tube product was stored?
shelves refer to shelf; down tube is a product
SELECT T2.Shelf FROM Product AS T1 INNER JOIN ProductInventory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Down Tube'
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
Please list the top 5 products with the most orders.
most order refers to Max(OrderQty);
SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.Name ORDER BY SUM(T2.OrderQty) DESC 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
What goods were sold to customers in accordance with sales order number 43660?
goods refers to products
SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesOrderID = 43660
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...
image_and_language
Name the most common predicate class of image ID 4434.
the most common predicate class of image ID 4434 MAX(PRED_CLASS) where IMG_ID = 4434;
SELECT T2.PRED_CLASS FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.IMG_ID = 4434 ORDER BY T2.PRED_CLASS DESC LIMIT 1
CREATE TABLE OBJ_CLASSES ( OBJ_CLASS TEXT not null, -- OBJ_CLASS_ID INTEGER default 0 not null primary key, ); CREATE TABLE ATT_CLASSES ( ATT_CLASS TEXT not null, -- ATT_CLASS_ID INTEGER default 0 not null primary key, ); CREATE TABLE IMG_OBJ_ATT ( IMG_ID INTEGER default 0 not null, -- foreign key (IMG_ID...
retails
Please indicate the names of the customers whose order with a total price over $300000.
customer name refers to c_name; a total price over $300000 refers to o_totalprice > 300000
SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice > 300000
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
List the comments describing orders from customers in the furniture segment.
comment refers to o_comment; furniture segment refers to c_mktsegment = 'FURNITURE'
SELECT T1.o_comment FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'FURNITURE'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
image_and_language
How many 'has' predicate classes does image ID 107 have?
has' predicate classes refers to PRED_CLASS = 'has'; image ID 107 refers to IMG_ID = 107;
SELECT COUNT(T2.PRED_CLASS) FROM IMG_REL AS T1 INNER JOIN PRED_CLASSES AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID WHERE T1.IMG_ID = 107 AND T2.PRED_CLASS = 'has'
CREATE TABLE OBJ_CLASSES ( OBJ_CLASS TEXT not null, -- OBJ_CLASS_ID INTEGER default 0 not null primary key, ); CREATE TABLE ATT_CLASSES ( ATT_CLASS TEXT not null, -- ATT_CLASS_ID INTEGER default 0 not null primary key, ); CREATE TABLE IMG_OBJ_ATT ( IMG_ID INTEGER default 0 not null, -- foreign key (IMG_ID...
retails
List the 5 orders with the highest total price, indicating the delivery date.
order refers to o_orderkey; the highest total price refers to max(o_totalprice); delivery date refers to l_shipdate
SELECT T1.o_orderkey, T2.l_shipdate FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey ORDER BY T1.o_totalprice DESC LIMIT 5
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
How many cars in the database are originated from Europe?
originated from Europe refers to country = 'Europe'
SELECT COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'Europe'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
Name of customer whose order is applied with the highest discount.
customer name refers to c_name; the highest discount refers to max(l_discount)
SELECT T3.c_name FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey INNER JOIN customer AS T3 ON T1.o_custkey = T3.c_custkey ORDER BY T2.l_discount DESC LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
What is the average price of cars with 8 cylinders?
with 8 cylinders refers to cylinders = 8; average price = avg(price) where cylinders = 8
SELECT AVG(T2.price) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.cylinders = 8
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List the phone numbers of customers whose order priority is urgent.
phone number refers to c_phone; order priority is urgent refers to o_orderpriority = '1-URGENT'
SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderpriority = '1-URGENT'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
What is the maximum sweep volume of a car that costs less than $30000?
cost less than $30000 refers to price < 30000; the maximum sweep volume = max(divide(displacement, cylinders)) where price < 30000
SELECT MAX(T1.displacement / T1.cylinders) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price < 30000
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
How many customers belong to the household segment in Germany?
household segment refers to c_mktsegment = 'household'; Germany refers to n_name = 'Germany'
SELECT COUNT(T1.c_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'GERMANY'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
What are the miles per gallon of the most expensive car?
miles per gallon refers to mpg; the most expensive refers to max(price)
SELECT T1.mpg FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T2.price DESC LIMIT 1
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List the names of customers whose accounts are in debt.
name of customer refers to c_name; account in debt refers to c_acctbal < 0
SELECT c_name FROM customer WHERE c_acctbal < 0
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
Which line item with the highest quantity is shipped by air?
line item refers to l_linenumber; the highest quantity refers to max(l_quantity); shipped by air refers to l_shipmode = 'AIR'
SELECT l_linenumber FROM lineitem WHERE l_shipmode = 'AIR' ORDER BY l_quantity DESC LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Please list the weights of all the cars with the price over $40000.
price over $40000 refers to price > 40000
SELECT T1.weight FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price > 40000
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
How many line items were returned in 1998?
line item refers to l_linenumber; returned refers to returnflag = 'R'; in 1998 refers to year(l_shipdate) = 1998
SELECT l_linenumber FROM lineitem WHERE STRFTIME('%Y', l_shipdate) < 1997 AND l_shipmode = 'TRUCK'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
List line items shipped by truck with delivery time before 1997.
line item refers to l_linenumber; shipped by truck refers to l_shipmode = 'truck'; delivery time before 1997 refers to year(l_shipdate) < 1997
SELECT l_linenumber FROM lineitem WHERE STRFTIME('%Y', l_shipdate) < 1997 AND l_shipmode = 'truck'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Which is the origin country of the $44274.40748 car?
origin country refers to country; the $44274.40748 car refers to price = 44274.40748
SELECT T3.country FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.price = 44274.40748
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
How many order keys are not applied for the discount?
order key refers to l_orderkey; not applied for the discount refers to l_discount = 0
SELECT COUNT(l_orderkey) FROM lineitem WHERE l_discount = 0
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
Please indicate the total price of order key 32.
total price refers to o_totalprice; order key 32 refers to o_orderkey = 32
SELECT o_totalprice FROM orders WHERE o_orderkey = 32
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Show the origin country of Chevrolet Malibu.
origin country refers to country; Chevrolet Malibu refers to car_name = 'chevrolet malibu'
SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.car_name = 'chevrolet malibu'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
What proportion of suppliers are from Asia?
Asia refers to r_name = 'ASIA'; proportion = divide(count(s_name where r_name = 'ASIA'), count(s_name)) * 100%
SELECT CAST(SUM(IIF(T1.r_name = 'ASIA', 1, 0)) AS REAL) * 100 / COUNT(T1.r_regionkey) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey INNER JOIN supplier AS T3 ON T2.n_nationkey = T3.s_nationkey
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
Which part and supplier have the most profit?
part refers to p_name; supplier refers to s_name; the most profit refers to max(subtract(multiply(l_extendedprice, subtract(1, l_discount)), multiply(ps_supplycost, l_quantity)))
SELECT T3.p_name, T4.s_name FROM partsupp AS T1 INNER JOIN lineitem AS T2 ON T1.ps_suppkey = T2.l_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey INNER JOIN supplier AS T4 ON T1.ps_suppkey = T4.s_suppkey ORDER BY T2.l_extendedprice * (1 - T2.l_discount) - T1.ps_supplycost * T2.l_quantity DESC LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Tell the origin country of car no.382.
origin country refers to country; car no.382 refers to ID = 382
SELECT DISTINCT T2.country FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T1.ID = 382
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List all the addresses for the suppliers of the biggest parts.
addresses refers to s_address; the biggest part refers to max(p_size)
SELECT T2.s_address FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey ORDER BY T3.p_size DESC LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Provide the engine displacement status of the $37443.85589 car.
engine displacement status refers to displacement; the $37443.85589 car refers to price = 37443.85589
SELECT T1.displacement FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = '37443.85589'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
What are the top 5 nations of suppliers with the lowest account balance?
nation refers to n_name; the lowest account balance refers to min(s_acctbal)
SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey ORDER BY T1.s_acctbal LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
What are the clerks of orders with line items shipped by mail?
clerk refers to o_clerk; shipped by mail refers to l_shipmode = 'MAIL'
SELECT T1.o_clerk FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T2.l_shipmode = 'MAIL'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
What is the maximum acceleration of a car with price over $40000?
the maximum acceleration refers to max(acceleration); price over $40000 refers to price > 40000
SELECT MAX(T1.acceleration) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price > 40000
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List the phone number of the customer who placed orders with a total price of more than $300,000.
phone number refers to c_phone; a total price of more than $300,000 refers to o_totalprice > 300000
SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice > 300000
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
What is the region with the most customers?
region refers to r_name; the most customers refers to max(count(c_custkey))
SELECT T.r_name FROM ( SELECT T3.r_name, COUNT(T2.c_custkey) AS num FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey GROUP BY T3.r_name ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
How many cylinders does the cheapest car have?
the cheapest car refers to min(price)
SELECT T1.cylinders FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY price ASC LIMIT 1
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
Which nation does the supplier with the account balance of "4393.04" belong to?
nation refers to n_name; account balance of "4393.04" refers to s_acctbal = 4393.04
SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal = 4393.04
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
How much is the Volkswagen Dasher with 14.1 mph acceleration?
cost refers to price; Volkswagen Dasher refers to car_name = 'volkswagen dasher'; 14.1 mph acceleration refers to acceleration = 14.1
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'volkswagen dasher' AND T1.acceleration = '14.1'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
What is the account balance of the supplier with the most parts?
account balance refers to s_acctbal; the most parts refers to max(count(ps_suppkey))
SELECT T.s_acctbal FROM ( SELECT T1.s_acctbal, COUNT(T2.ps_suppkey) AS num FROM supplier AS T1 INNER JOIN partsupp AS T2 ON T1.s_suppkey = T2.ps_suppkey GROUP BY T1.s_suppkey ) AS T ORDER BY T.num DESC LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
What are the shipping methods for the orders on 12/31/1994?
shipping method refers to l_shipmode; order on 12/31/1994 refers to o_orderdate = '1994-12-31'
SELECT DISTINCT T2.l_shipmode FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderdate = '1994-12-31'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Provide the price of the only Toyota Corona hardtop in the database.
Toyota Corona hardtop refers to car_name = 'toyota corona hardtop'
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'toyota corona hardtop'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
What is the total price of all orders from the customer with the phone number "627-220-3983"?
total price = sum(o_totalprice); phone number "627-220-3983" refers to c_phone = '627-220-3983'
SELECT SUM(T1.o_totalprice) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_phone = '627-220-3983'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
State the origin country of the fastest car in the database.
origin country refers to country; the fastest refers to max(horsepower)
SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country ORDER BY T1.horsepower DESC LIMIT 1
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List all the customers' phone numbers from Ethiopia.
phone number refers to c_phone; Ethiopia refers to n_name = 'Ethiopia'
SELECT T1.c_phone FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'Ethiopia'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
What is the supply cost for the part "violet olive rose ivory sandy"?
supply cost refers to ps_supplycost; part "violet olive rose ivory sandy" refers to p_name = 'violet olive rose ivory sandy'
SELECT T2.ps_supplycost FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T1.p_name = 'violet olive rose ivory sandy'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
When was the $32650.65157 car introduced to the market? State the year.
the $32650.65157 car refers to price = 32650.65157; year refers to model
SELECT T1.model FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = '32650.65157'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List all the nations in Europe.
nation refers to n_name; Europe refers to r_name = 'EUROPE'
SELECT T2.n_name FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey WHERE T1.r_name = 'EUROPE'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Which car in the database provides the best crash protection based on its weight? How much is it?
the best crash protection refers to max(weight); cost refers to price
SELECT T1.ID, T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T1.weight DESC LIMIT 1
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
How many part supplies are close to being out of stock?
close to being out of stock refers to ps_availqty < 10
SELECT COUNT(ps_suppkey) FROM partsupp WHERE ps_availqty < 10
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
What is the largest supplier's account balance?
the largest supplier's account balance refers to max(s_acctbal)
SELECT MAX(s_acctbal) FROM supplier
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Calculate the swept volume of the $34538.97449 car.
sweep volume = divide(displacement, cylinders); the $34538.97449 car refers to price = 34538.97449
SELECT T1.displacement / T1.cylinders FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = 34538.97449
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
How many of the items are instructed to be delivered in person?
instructed to be delivered in person refers to l_shipinstruct = 'DELIVER IN PERSON'
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipinstruct = 'DELIVER IN PERSON'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
Among the cars with an acceleration of over 10 miles per squared hour, how many of them cost more than $20000 and less than $30000?
an acceleration of over 10 miles per squared hour refers to acceleration > 10; cost more than $20000 and less than $30000 refers to price < 30000 AND price > 20000
SELECT COUNT(*) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.acceleration > 10 AND T2.price BETWEEN 20000 AND 30000
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
List all the dates of the urgent orders.
date refers to o_orderdate; urgent order refers to o_orderpriority = '1-URGENT'
SELECT o_orderdate FROM orders WHERE o_orderpriority = '1-URGENT'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
Which customer is the most in debt?
customer refers to c_name; the most in debt refers to max(c_acctbal)
SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer )
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
How many Japanese suppliers have their accounts in debt?
Japanese refers to n_name = 'Japan'; have accounts in debt refers to s_acctbal < 0
SELECT COUNT(T1.s_suppkey) FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 AND T2.n_name = 'JAPAN'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
How much is the car with the highest sweep volume?
cost refers to price; the highest sweep volume refers to max(divide(displacement, cylinders))
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T1.displacement / T1.cylinders DESC LIMIT 1
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
What is the delivery time and the clerk of order number 6?
delivery time = subtract(l_receiptdate, l_commitdate); clerk refers to o_clerk; order number 6 refers to o_orderkey = 6
SELECT JULIANDAY(T2.l_receiptdate) - JULIANDAY(T2.l_commitdate), T1.o_clerk FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderkey = 6
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
Which nation and region does the Customer#000000008 come from?
nation refers to n_name; region refers to r_name; Customer#000000008 refers to c_name = 'Customer#000000008'
SELECT T1.n_name, T3.r_name FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.c_name = 'Customer#000000008'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
What is the percentage of Japanese cars in the database?
Japanese car refers to country = 'Japan'; percentage = divide(count(ID where country = 'Japan'), count(ID)) * 100%
SELECT CAST(SUM(CASE WHEN T2.country = 'Japan' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
What is the name of the customer number 93697 with the total order price of 191918.92?
customer name refers to c_name; number 93697 refers to o_custkey = 93697; total order price of 191918.92 refers to o_totalprice = 191918.92
SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice = 191918.92 AND T1.o_custkey = 93697
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
How many customers from the furniture segments come from Iraq?
furniture segment refers to c_mktsegment = 'FURNITURE'; Iraq refers to n_name = 'Iraq'
SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'FURNITURE' AND T2.n_name = 'IRAQ'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
How many cars were released in the USA in 1981?
in the USA refers to country = 'USA'; in 1981 refers to model_year = 1981
SELECT COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'USA' AND T1.model_year = 1981
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...
retails
Which region has the lowest number of countries?
region refers to has r_name; the lowest number of countries refers to min(count(n_name))
SELECT T.r_name FROM ( SELECT T1.r_name, COUNT(T2.n_name) AS num FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey GROUP BY T1.r_name ) AS T ORDER BY T.num LIMIT 1
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
retails
What are the countries that belong to Africa?
country is nation name which refers to n_name; Africa is region name refers to r_name = 'Africa'
SELECT T2.n_name FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey WHERE T1.r_name = 'Africa'
CREATE TABLE partsupp ( ps_supplycost REAL not null, -- foreign key (ps_suppkey) references supplier (s_suppkey) on update cascade on delete cascade, ps_comment TEXT null, -- ps_availqty INTEGER null, -- ps_suppkey INTEGER not null, -- ps_partkey INTEGER not null, -- primary key (ps_partkey, ps_suppkey...
cars
How many times was Ford Maverick introduced to the market?
Ford Maverick refers to car_name = 'ford maverick';
SELECT COUNT(T2.model_year) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'ford maverick'
CREATE TABLE data ( foreign key (ID) references price(ID), acceleration REAL, -- model INTEGER, -- Example Values: `70`, `71`, `72`, `73`, `74` | Value Statics: Total count 398 - Distinct count 13 - Null count 0 horsepower INTEGER, -- weight INTEGER, -- displacement REAL, -- ID INTEGER primary key, c...