db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
chicago_crime
Who is the commanding officer in the district with the highest number of reported crimes where no arrest has been made?
where no arrest refers to arrest = 'FALSE'; highest number of crime refers to Max(Count(report_no)); commanding officer refers to commander
SELECT T2.commander FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.arrest = 'FALSE' GROUP BY T2.commander ORDER BY COUNT(T1.report_no) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
How many of the approved documents are confidential?
approved refers to Status = 2; confidential document refers to DocumentSummary is null;
SELECT COUNT(DocumentNode) FROM Document WHERE Status = 2 AND DocumentSummary IS NULL
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 job title of the newest employee in department 12?
newest employee refers to MAX(StartDate)
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
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List all of the award winners' birth dates.
award winner refers to result = 'Winner'
SELECT T1.birthdate FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.result = 'Winner';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
chicago_crime
How many severe crime incidents were reported at coordinate 41.64820151, -87.54430496?
coordinates refers to latitude, longitude; severe crime refers to index_code = 'I'
SELECT SUM(CASE WHEN T1.longitude = '-87.54430496' THEN 1 ELSE 0 END) FROM Crime AS T1 INNER JOIN IUCR AS T2 ON T1.report_no = T2.iucr_no WHERE T2.index_code = 'I' AND T1.latitude = '41.64820251'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
How many materials still need to be assembled and have a depth of 2 between each component and their parent product?
still need to be assembled means the assembly doesn't finish or still going on which refers to EndDate IS NULL; a depth of 2 refers to BOMLevel = 2;
SELECT COUNT(*) FROM BillOfMaterials WHERE BOMLevel = 2 AND EndDate IS NULL
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
Calculate the number of products if we add the products of the accessories and components categories.
null
SELECT COUNT(ProductID) FROM Product WHERE Name LIKE '%accessories %' OR Name LIKE '%components%'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
regional_sales
How many stores procured products on October 27, 2018, in the city of Oregon?
October 27, 2018 refers to ProcuredDate = '10/27/18'; 'Oregon' is the State
SELECT SUM(CASE WHEN T1.ProcuredDate = '10/27/18' AND T2.`City Name` = 'Orlando' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
Which community has the highest number of neighborhoods?
community with highest number of neighborhoods refers to Max(Count(community_area_no)); community refers to community_area_name
SELECT T1.community_area_name FROM Community_Area AS T1 INNER JOIN Neighborhood AS T2 ON T1.community_area_no = T2.community_area_no ORDER BY T2.community_area_no DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
What is the difference between the actual manufacturing cost of product number 818 and the estimated manufacturing cost?
product number 818 refers to ProductID = 818; estimated manufacturing cost refers PlannedCost; actual manufacturing cost refers to ActualCost; difference = Substract(PlannedCost(ProductID(818))),(ActualCost(ProductID(818)));
SELECT PlannedCost - ActualCost FROM WorkOrderRouting WHERE ProductID = 818
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 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?
last receipt date is August 17, 2011 refers to LastReceiptDate> = '2011-08-17 00:00:00' and LastReceiptDate < '2011-08-18 00:00:00';
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'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List down the title of episode S20-E1, S20-E2 & S20-E3.
episode S20-E1, S20-E2 & S20-E3 refers to episode_id = 'S20-E1' and episode_id = 'S20-E2' and episode_id = 'S20-E3'
SELECT title FROM Episode WHERE episode_id IN ('S20-E1', 'S20-E2', 'S20-E3');
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
What type of store is most popular in the South?
in the South refers to Region = 'South'; type of store that is most popular refers to Max(Count(Type))
SELECT DISTINCT CASE WHEN MAX(T2.Population) THEN T2.Type END FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
Who is the crime against criminal sexual abuse?
"Criminal Sexual Abuse" is the title of crime
SELECT crime_against FROM FBI_Code WHERE title = 'Criminal Sexual Abuse'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
What is the highest possible discount rate for 'Excess Inventory'?
excess inventory refers to Type = 'Excess Inventory'; highest possible discount refers to Max(DiscountPct);
SELECT DiscountPct FROM SpecialOffer WHERE Type = 'Excess Inventory' ORDER BY DiscountPct 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 company has a Colonial Voice card that expired in March 2005?
Colonial Voice card refers to CardType = 'ColonialVoice' ; expired in March 2005 refers to ExpMonth = 3, ExpYear = 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
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Which country has the tallest person in the crew?
country refers to birth_country; tallest person refers to max(height_meters)
SELECT birth_country FROM Person ORDER BY height_meters DESC LIMIT 1;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
List the 5 sales teams that have made sales with the highest net profits.
highest net profit = Max(Subtract (Unit Price, Unit Cost))
SELECT T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID ORDER BY REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '') DESC LIMIT 5
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
Which product did Cruz & Sons Co. order on 2003/3/3?
Cruz & Sons Co. is name of customer; 2003/3/3 refers to orderDate;
SELECT t4.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode WHERE t3.customerName = 'Cruz & Sons Co.' AND t2.orderDate = '2003-03-03'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
chicago_crime
How many districts are there in the police district building with a zip code of 60608?
district refers to district_name
SELECT COUNT(*) AS cnt FROM District WHERE zip_code = 60608
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
What categories of offers qualify for group discounts for resellers?
resellers refers to Category = 'Reseller';
SELECT Type FROM SpecialOffer WHERE Category = 'Reseller'
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
Identifies the ID number of the customer whose sales order for 32 units had a unit price of 35.
sales order for 32 units refers to OrderQty = 32
SELECT T2.CustomerID FROM SalesOrderDetail AS T1 INNER JOIN Customer AS T2 WHERE T1.UnitPrice = 35 AND T1.OrderQty = 32
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
State the number of votes for episode with rating of 7 and above.
rating of 7 and above refers to rating > 7.0
SELECT votes FROM Episode WHERE rating > 7;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
car_retails
When were the products ordered by Cruz & Sons Co. on 2003-03-03 shipped?
Cruz & Sons Co. is name of customer; ordered on 2003-03-03 refers to orderDate;
SELECT t1.shippedDate FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.customerName = 'Cruz & Sons Co.' AND t1.orderDate = '2003-03-03'
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
chicago_crime
How many crime against property are there?
null
SELECT COUNT(*) AS cnt FROM FBI_Code WHERE crime_against = 'Property'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Which three sales regions have generated the most revenue thus far?
revenue refers to SalesYTD; the most revenue refers to Max(SalesYTD);
SELECT TerritoryID FROM SalesTerritory ORDER BY SalesYTD DESC 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
Add the number of businesses that indicate their home address as their address and those whose address corresponds to the shipping address.
their home address as their address refers to AddressTypeID = 2; address corresponds to the shipping address refers to AddressTypeID = 5
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
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
How many people were not born in Connecticut, USA?
not born in Connecticut, USA refers to birth_region ! = 'Connecticut' and birth_country ! = 'USA'
SELECT COUNT(name) FROM Person WHERE birth_region != 'Connecticut' AND birth_country != 'USA';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many different time zones are there in the Northeast region?
null
SELECT COUNT(DISTINCT T2.`Time Zone`) FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T1.Region = 'Northeast'
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
What are the full names of the top 5 most crowded ward aldermen?
most crowded ward refers to Max(Population); full name of alderman refers to alderman_first_name, alderman_last_name
SELECT alderman_first_name, alderman_last_name FROM Ward ORDER BY Population DESC LIMIT 5
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Please list three businesses with the lowest total sales from last year.
lowest total sales in last year refers to Min(SalesLastYear);
SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesLastYear 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
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.
increased their current year sales by more than 60% refers to DIVIDE(SUBTRACT(SalesYTD, SalesLastYear),SalesLastYear)>0.6
SELECT BusinessEntityID FROM SalesPerson WHERE SalesYTD > SalesLastYear + SalesLastyear * 0.6 AND Bonus > 3000
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
How many people who were born after 1970 are animation executive producer?
born after 1980 refers to birthdate > 1970; assistant to the producers refers to role = 'animation executive producer'
SELECT COUNT(*) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE STRFTIME(T1.birthdate) > '1970' AND T2.role = 'animation executive producer';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
In which city is the store with the highest sales order unit price located?
highest sales order unit price refers to Max(Unit Price)
SELECT T2.`City Name` FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE REPLACE(T1.`Unit Price`, ',', '') = ( SELECT REPLACE(T1.`Unit Price`, ',', '') FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID ORDER BY REPLACE(T1.`Unit Price`, '...
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
What is the average population of the wards where apartment crimes have been reported without arrests?
apartment crime refers to location_description = 'APARTMENT';  without arrest refers to arrest = 'FALSE'; average population = AVG(Population)
SELECT AVG(T2.Population) FROM Crime AS T1 INNER JOIN Ward AS T2 ON T2.ward_no = T1.ward_no WHERE T1.location_description = 'APARTMENT' AND T1.arrest = 'FALSE'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
What are the differences between the 288th salesperson's predicted annual sales and his or her actual sales thus far?
288th sales person refers to BusinessEntityID = 288; predited annual sales refers to SalesQuota; actual sales refers to SalesYTD; difference = Substract(SalesQuota(BusinessEntityID(288))), (SalesYTD(BusinessEntityID(288)));
SELECT SalesYTD - SalesQuota FROM SalesPerson WHERE BusinessEntityID = 288
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 percentage, by number of sales order units, for orders with quantities not greater than 3 and a discount of 0.2?
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%
SELECT CAST(SUM(CASE WHEN OrderQty < 3 AND UnitPriceDiscount = 0.2 THEN 1 ELSE 0 END) AS REAL) / COUNT(SalesOrderID) FROM SalesOrderDetail
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Write down the website address which stores the episode image of episode 5.
website address refers to episode_image
SELECT episode_image FROM Episode WHERE episode = 5;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
What are the top 10 products with the highest net profit?
products refers to Product Name; highest net profit = Max(Subtract(Unit Price, Unit Cost))
SELECT T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID GROUP BY T1._ProductID ORDER BY SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) DESC LIMIT 10
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
What percentage of non-domestic crimes have occurred in the Jefferson Park district?
non domestic crime refers to domestic = 'FALSE'; 'Jefferson Park' is the district_name; percentage = Divide (Count (case_number where domestic = 'FALSE'), Count(case_number)) * 100
SELECT CAST(COUNT(CASE WHEN T2.domestic = 'FALSE' THEN T2.case_number END) AS REAL) * 100 / COUNT(T2.case_number) FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no WHERE T1.district_name = 'Jefferson Park'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Please provide the IDs of any three AdventureWorks product subcategories.
null
SELECT DISTINCT ProductCategoryID FROM ProductSubcategory 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 average total due price of products with approved status?
approved refers to Status = 2 , average total due price = AVG( DIVIDE(TotalDue, SUM(Status = 2 )))
SELECT SUM(TotalDue) / COUNT(TotalDue) FROM PurchaseOrderHeader WHERE Status = 2
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
How many additional timers were born in USA?
additional timers refers to role = 'additional timer'; born in USA refers to birth_country = 'USA'
SELECT COUNT(*) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.role = 'additional timer' AND T1.birth_country = 'USA';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many stores with less need for products, and purchased through a distributor, are located in Washtenaw County?
less need for products refers to Order Quantity = 1; purchased through a distributor refers to Sales Channel = 'Distributor'; 'Harri County' is the County
SELECT SUM(CASE WHEN T1.`Order Quantity` = 1 AND T1.`Sales Channel` = 'Distributor' AND T2.County = 'Washtenaw County' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
Which commander has had to deal with more cases of criminal sexual abuse?
more cases of criminal sexual abuse refers to Max(Count(secondary_description = 'CRIMINAL SEXUAL ABUSE'))
SELECT T3.commander FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T1.secondary_description = 'CRIMINAL SEXUAL ABUSE' GROUP BY T3.commander ORDER BY COUNT(T1.secondary_description) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Calculate the average age of employee in each department and state which department has the youngest employees.
Average = Divide(Sum(Substract(year(@today),year(BirthDate))),Count(BusinessEntityID) by each Department ID; youngest employee refers to Min(BirthDate);
SELECT STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.BirthDate) + 1 , T3.Name FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (BusinessEntityID) INNER JOIN Department AS T3 USING (DepartmentID) ORDER BY 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
List, by ProductID, all products whose profit, relative to the standard price, is negative.
Profit = SUBTRACT(StandardPrice, LastRecipeCost)
SELECT DISTINCT ProductID FROM ProductVendor WHERE StandardPrice - LastReceiptCost < 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...
chicago_crime
In which ward of more than 55,000 inhabitants are there more crimes of intimidation with extortion?
more than 55000 inhabitants refers to Population > 55000; 'INTIMIDATION' is the primary_description; 'EXTORTION' refers to secondary_description; more crime refers to Count(ward_no)
SELECT T3.ward_no FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN Ward AS T3 ON T3.ward_no = T2.ward_no WHERE T1.primary_description = 'INTIMIDATION' AND T1.secondary_description = 'EXTORTION' AND T3.Population > 55000 GROUP BY T3.ward_no ORDER BY COUNT(T3.ward_no) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
State the employee who are born in or after 1970 and with the least sick leave hour.
born in or after 1970 refers to year(BirthDate) > = 1970;
SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.BirthDate) > '1970' ORDER BY T1.SickLeaveHours 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 percentage of people named Mary who wants Receive Email promotions of AdventureWorks and selected partners are store contacts?
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)))
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'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List down the rating of episodes that were produced by Jason Bikowski.
produced by Jason Bikowski refers to person = 'Jason Bikowski'
SELECT T1.rating FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Jason Bikowski';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
To which region does the sales team that has used the WARE-MKL1006 warehouse the most times for its shipments belong?
"WARE-MKL1006" is the WarehouseCode; most shipment to region refers to Max(Count(Region))
SELECT T2.Region FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.WarehouseCode = 'WARE-MKL1006' GROUP BY T2.Region ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
What types of domestic crimes have occurred the most in the North Lawndale community?
"North Lawndale' is the community_area_name; occur the most domestic crime refers to Max(Count(domestic = 'TRUE'))
SELECT T2.domestic FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.community_area_name = 'North Lawndale' AND T2.domestic = 'TRUE' GROUP BY T2.domestic ORDER BY COUNT(T2.domestic) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Find the vendor with the least average lead time for Product ID 348.
null
SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ProductID = 348 ORDER BY T1.AverageLeadTime ASC LIMIT 1
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
works_cycles
What percentage of male employees hired throughout the years 2009 are married?
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)))
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'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
How many title's crew members are working from Casting Department?
working from Casting Department refers to category = 'Casting Department'
SELECT COUNT(*) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.category = 'Casting Department';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
chicago_crime
In which district have there been more intimidation-type crimes?
more intimidation-type crime refers to Max(Count(primary_description = 'INTIMIDATION')); district refers to district_name
SELECT T3.district_name FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T1.primary_description = 'INTIMIDATION' GROUP BY T3.district_name ORDER BY COUNT(T1.primary_description) DESC LIMIT 1
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
State the vendor for product number WB-H098.
null
SELECT T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.ProductNumber = 'WB-H098'
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
Average cost of purchase orders made during the first six months of 2012.
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))
SELECT CAST(SUM(ActualCost) AS REAL) / COUNT(TransactionID) FROM TransactionHistoryArchive WHERE TransactionType = 'P' AND TransactionDate >= '2012-01-01' AND TransactionDate < '2012-07-01'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Write down the summary of episode whereby it has crew members that are not included in the credit list.
are not included in the credit list refers to credited = ''
SELECT T1.summary FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.credited = 'false';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many online purchases did Ole Group make in May 2019?
"Ole Group" is the Customer Names; online purchase refers to Sales Channel = 'Online'; made in May 2019 refers to OrderDate LIKE '5/%/19'
SELECT SUM(CASE WHEN T1.`Sales Channel` = 'Online' AND T2.`Customer Names` = 'Ole Group' AND T1.OrderDate LIKE '5/%/19' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
How many crimes described as 'The theft of a motor vehicle' by the FBI have taken place in the Lake View community?
lake view community refers to community_area_name = 'Lake View'; 'The theft of a motor vehicle' is the description
SELECT SUM(CASE WHEN T3.community_area_name = 'Lake View' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T2.fbi_code_no = T1.fbi_code_no INNER JOIN Community_Area AS T3 ON T3.community_area_no = T2.community_area_no WHERE T1.description = 'The theft of a motor vehicle.'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Who is the oldest married male? State his job title.
Male refers to Gender = 'M'; married refers to MaritalStatus = 'M'; oldest refers to Min(BirthDate);
SELECT T2.FirstName, T2.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate 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
Average of the last receipt cost of the products whose average lead time is 60 days.
average = DIVIDE(SUM(lastreceiptcost), COUNT(OnorderQty)) where AverageLeadTime = 60
SELECT SUM(LastReceiptCost) / COUNT(ProductID) FROM ProductVendor WHERE AverageLeadTime = 60
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the character that won the award in Primetime Emmy 2009?
won the award in Primetime Emmy 2009 refers to award_category = 'Primetime Emmy' and year = 2009
SELECT DISTINCT T2.character FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.award_category = 'Primetime Emmy' AND T1.year = 2009 AND T1.result = 'Winner';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
chicago_crime
What phone number does alderman Emma Mitts have to call if she wants to speak to the commander in charge of the investigation of the crimes that have occurred in her ward?
null
SELECT T3.phone FROM Ward AS T1 INNER JOIN Crime AS T2 ON T2.ward_no = T1.ward_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T1.alderman_first_name = 'Emma' AND T1.alderman_last_name = 'Mitts'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
List all product only MOQ of 1,000 and with standard cost more than 17.
MOQ refers to minimum order quantity; MOQ of 1 refers to MinOrderQty = 1; standard cost more than 48 refers to StandardCost > 48;
SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaxOrderQty = 1000 AND T2.StandardCost > 17
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 active employees with over 10 hours of sick leave, what is the percentage of the employees with over 20 vacation hours?
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;
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
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What are the keywords for episode 426 of the series?
episode 426 refers to number_in_series = 426
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.number_in_series = 426;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many states are in the Midwest region?
null
SELECT COUNT(DISTINCT T) FROM ( SELECT CASE WHEN Region = 'Midwest' THEN State ELSE NULL END AS T FROM Regions ) WHERE T IS NOT NULL
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
car_retails
What is the amount of customers of 1957 Chevy Pickup by customers in a month?
null
SELECT COUNT(T2.customerNumber) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.productCode IN ( SELECT productCode FROM products WHERE productName = '1957 Chevy Pickup' )
CREATE TABLE offices ( phone TEXT not null, -- Example Values: `+1 650 219 4782`, `+1 215 837 0825`, `+1 212 555 3000`, `+33 14 723 4404`, `+81 33 224 5000` | Value Statics: Total count 7 - Distinct count 7 - Null count 0 addressLine1 TEXT not null, -- Example Values: `100 Market Street`, `1550 Court Place`, `523 ...
chicago_crime
How many crimes against society happened in the Wentworth district according to the FBI?
"Wentworth" is the district_name; crime against society refers to crime_against = 'Society"
SELECT SUM(CASE WHEN T1.crime_against = 'Society' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T2.fbi_code_no = T1.fbi_code_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T3.district_name = 'Wentworth'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Names the Sales Representative with the highest year to date sales.
Highest year to date sales refers to Max(SalesYTD);
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.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
If a married employee has a western name style, what is the probability of him or her working as a store contact?
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'))
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'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
List down the keyword and crew member's name for episode id S20-E1.
null
SELECT T1.keyword, T2.person FROM Keyword AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode_id = 'S20-E1';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
chicago_crime
How many domestic crime cases has Commander Ronald A. Pontecore Jr. been responsible for investigating?
domestic crime refers to domestic = 'TRUE'; person responsible for investigating refers to commander
SELECT SUM(CASE WHEN T2.domestic = 'TRUE' THEN 1 ELSE 0 END) FROM District AS T1 INNER JOIN Crime AS T2 ON T2.district_no = T1.district_no WHERE T1.commander = 'Ronald A. Pontecore Jr.'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Name all products that started selling in 2013. State its respective vendor's name.
Started selling in 2013 refers to year(SellStartDate) = 2013;
SELECT T1.Name, T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE STRFTIME('%Y', T1.SellStartDate) = '2013'
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 are married and wish to receive e-mail promotions, how much higher is their highest pay rate from the average pay rate?
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...
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'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the average heights of crew members from Animation Department?
from Animation Department refers to category = 'Animation Department'; AVG(height_meters) where category = 'Animation Department'
SELECT AVG(T1.height_meters) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.category = 'Animation Department';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
At what Latitude and Longitude is the store that has used the WARE-PUJ1005 warehouse the fewest times?
WARE-PUJ1005 is the WarehouseCode; fewest times refers to Min (Count(WarehouseCode))
SELECT T2.Latitude, T2.Longitude FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.WarehouseCode = 'WARE-PUJ1005' GROUP BY T2.StoreID ORDER BY COUNT(T1.WarehouseCode) ASC LIMIT 1
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
How many different types of crimes, according to the primary description, have occurred in the Hermosa neighborhood?
"Hermosa" is the neighborhood_name
SELECT SUM(CASE WHEN T4.neighborhood_name = 'Hermosa' THEN 1 ELSE 0 END) FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN Community_Area AS T3 ON T3.community_area_no = T2.community_area_no INNER JOIN Neighborhood AS T4 ON T4.community_area_no = T3.community_area_no
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Name all stores and its sales representative in France territory.
France territory refers to SalesTerritory.Name = 'France';
SELECT T3.Name, T4.FirstName, T4.LastName FROM SalesTerritory AS T1 INNER JOIN Customer AS T2 ON T1.TerritoryID = T2.TerritoryID INNER JOIN Store AS T3 ON T2.StoreID = T3.BusinessEntityID INNER JOIN Person AS T4 ON T2.PersonID = T4.BusinessEntityID WHERE T1.Name = 'France'
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 vacation hours do the male employees have on average?
employee refers to PersonType = 'EM'; Male refers to Gender = 'M'; Average = Divide( SUM(VacationHours(PersonType = 'EM'& Gender = 'M')),Count(BusinessEntityID(PersonType = 'EM' & Gender = 'M')));
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'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
Calculate the total votes of episodes that Adam Kuhlman had involved.
Adam Kuhlman had involved refers to person = 'Adam Kuhlman'
SELECT SUM(T1.votes) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Adam Kuhlman';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
chicago_crime
What is the exact location of the crimes that occurred in the Belmont Cragin community?
Belmont Cragin community refers to community_area_name = 'Belmont Cragin'; exact location refers to latitude, longitude
SELECT T2.latitude, T2.longitude FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T2.community_area_no = T1.community_area_no WHERE T1.community_area_name = 'Belmont Cragin' GROUP BY T2.latitude, T2.longitude
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Name the sales person for store Area Bike Accessories. Which territory is he / she in?
null
SELECT T4.Name FROM Store AS T1 INNER JOIN SalesPerson AS T2 ON T1.SalesPersonID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN SalesTerritory AS T4 ON T2.TerritoryID = T4.TerritoryID WHERE T1.Name = 'Area Bike Accessories'
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 credit card IDs of the employees who work as store contact.
store contact refers to PersonType = 'SC';
SELECT T2.CreditCardID FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SC'
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the percentage of star score 5 that was collected by title "Sex, Pies and Idiot Scrapes"?
percentage = DIVIDE(SUM(stars = 5), COUNT(stars)) as percentage
SELECT CAST(SUM(CASE WHEN T2.stars = 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.title = 'Sex, Pies and Idiot Scrapes';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
How many orders through distributor were for the minimum quantity?
"Distributor" is the Sales Channel; minimum quantity refers to Min(Order Quantity)
SELECT SUM(CASE WHEN `Order Quantity` = 1 AND `Sales Channel` = 'Distributor' THEN 1 ELSE 0 END) FROM `Sales Orders`
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
How many weapons violation crimes have occurred in the Calumet district?
"Calumet" is the district_name; 'WEAPON VIOLATION' is the primary_description of crime
SELECT SUM(CASE WHEN T3.district_name = 'Calumet' THEN 1 ELSE 0 END) FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T2.iucr_no = T1.iucr_no INNER JOIN District AS T3 ON T3.district_no = T2.district_no WHERE T1.primary_description = 'WEAPONS VIOLATION'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
List the person who owns a distinguish credt card.
distinguish credt card refers to cardType = 'Distinguish'
SELECT T3.FirstName, T3.LastName FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.CardType = 'Distinguish'
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 active employees do not wish to receive e-mail promotions?
active status of employees refers to CurrentFlag = 1; the employee does not wish to receive an e-mail promotion refers to EmailPromotion = 0;
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
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What are the characters that were nominated for Primetime Emmy Award from 2009 to 2010 but did not win?
nominated for Primetime Emmy Award but did not win refers to award_category = 'Primetime Emmy' and result = 'Nominee';  from 2009 to 2010 refers to year > = '2009' and  year < = '2010'
SELECT T2.character FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.award_category = 'Primetime Emmy' AND T1.year BETWEEN 2009 AND 2010 AND T1.result != 'Winner';
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
What is the average land area of ​​the cities in which stores that purchased products for a unit price of 998.30 are located?
average land area = Divide (Sum(Land Area), Count(Land Area))
SELECT AVG(T2.`Land Area`) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.`Unit Price` = '998.30'
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
List crimes that the FBI has classified as Drug Abuse by their report number.
"Drug Abuse" is the title of crime
SELECT T2.report_no FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T2.fbi_code_no = T1.fbi_code_no WHERE T1.title = 'Drug Abuse'
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...
works_cycles
Please provide contact details of all Marketing Managers. State their name and phone number.
Marketing Manager is a job title
SELECT T1.FirstName, T1.LastName, T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle = 'Marketing Manager'
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 married employees with the highest pay frequency, how many of them have an eastern name style?
married refers to MaritalStatus = 'M'; Eastern name style refers to NameStyle = 1;
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 ...
CREATE TABLE ProductSubcategory ( ProductCategoryID INTEGER not null, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 37 - Distinct count 4 - Null count 0 rowguid TEXT not null unique, -- ModifiedDate DATETIME default CURRENT_TIMESTAMP not null, -- Example Values: `2008-04-30 00:00:00.0` | Va...
simpson_episodes
What is the keyword for episodes with stars score of 10 at 30% and above?
stars score of 10 at 30% and above refers to stars = 10 and percent > 29
SELECT T1.keyword FROM Keyword AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 AND T2.percent > 29;
CREATE TABLE Keyword ( foreign key (episode_id) references Episode(episode_id), keyword TEXT, -- primary key (episode_id, keyword), episode_id TEXT, -- ); CREATE TABLE Vote ( foreign key (episode_id) references Episode(episode_id), votes INTEGER, -- episode_id TEXT, -- percent REAL, -- stars INTEGER...
regional_sales
What is the least purchased product by stores in the city of Santa Clarita?
least purchased product refers to Min(Count(Product Name)); 'Santa Clarita' is the City
SELECT T1.`Product Name` FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` AS T3 ON T3.StoreID = T2._StoreID WHERE T3.`City Name` = 'Santa Clarita' GROUP BY T1.`Product Name` ORDER BY COUNT(T1.`Product Name`) ASC LIMIT 1
CREATE TABLE Regions ( State TEXT, -- Region TEXT, -- Example Values: `South`, `West`, `Northeast`, `Midwest` | Value Statics: Total count 48 - Distinct count 4 - Null count 0 StateCode TEXT constraint Regions_pk primary key, ); CREATE TABLE Sales Orders ( OrderNumber TEXT constraint "Sales Orders_pk" primary...
chicago_crime
What is the first name of the aldermen of wards with more than 50,000 inhabitants?
more than 50000 inhabitants refers to Population > 50000; first name of alderman refers to alderman_first_name
SELECT alderman_first_name FROM Ward WHERE Population > 50000
CREATE TABLE District ( district_no INTEGER primary key, email TEXT, -- phone TEXT, -- address TEXT, -- fax TEXT, -- district_name TEXT, -- tty TEXT, -- commander TEXT, -- zip_code INTEGER, -- twitter TEXT, -- ); CREATE TABLE Community_Area ( population TEXT, -- side TEXT, -- Example Va...