db_id
stringlengths 4
28
| question
stringlengths 24
325
| evidence
stringlengths 0
673
| SQL
stringlengths 23
804
| schema
stringlengths 352
37.3k
|
---|---|---|---|---|
works_cycles | How many black-colored products are there that cannot be sold? | cannot be sold means product is not a salable item which refers to FinishedGoodsFlag = 0 | SELECT COUNT(ProductID) FROM Product WHERE FinishedGoodsFlag = 0 AND Color = 'Black' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
CountryRegionCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
CultureID TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
CurrencyCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
CountryRegionCode TEXT not null,
CurrencyCode TEXT not null,
ModifiedDate DATETIME default current_timestamp not null,
primary key (CountryRegionCode, CurrencyCode),
foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
BusinessEntityID INTEGER not null
primary key,
PersonType TEXT not null,
NameStyle INTEGER default 0 not null,
Title TEXT,
FirstName TEXT not null,
MiddleName TEXT,
LastName TEXT not null,
Suffix TEXT,
EmailPromotion INTEGER default 0 not null,
AdditionalContactInfo TEXT,
Demographics TEXT,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
BusinessEntityID INTEGER not null,
PersonID INTEGER not null,
ContactTypeID INTEGER not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
primary key (BusinessEntityID, PersonID, ContactTypeID),
foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
foreign key (ContactTypeID) references ContactType(ContactTypeID),
foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
BusinessEntityID INTEGER not null,
EmailAddressID INTEGER,
EmailAddress TEXT,
rowguid TEXT not null,
ModifiedDate DATETIME default current_timestamp not null,
primary key (EmailAddressID, BusinessEntityID),
foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
BusinessEntityID INTEGER not null
primary key,
NationalIDNumber TEXT not null
unique,
LoginID TEXT not null
unique,
OrganizationNode TEXT,
OrganizationLevel INTEGER,
JobTitle TEXT not null,
BirthDate DATE not null,
MaritalStatus TEXT not null,
Gender TEXT not null,
HireDate DATE not null,
SalariedFlag INTEGER default 1 not null,
VacationHours INTEGER default 0 not null,
SickLeaveHours INTEGER default 0 not null,
CurrentFlag INTEGER default 1 not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
BusinessEntityID INTEGER not null
primary key,
PasswordHash TEXT not null,
PasswordSalt TEXT not null,
rowguid TEXT not null,
ModifiedDate DATETIME default current_timestamp not null,
foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
BusinessEntityID INTEGER not null,
CreditCardID INTEGER not null,
ModifiedDate DATETIME default current_timestamp not null,
primary key (BusinessEntityID, CreditCardID),
foreign key (CreditCardID) references CreditCard(CreditCardID),
foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
ProductCategoryID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
ProductDescriptionID INTEGER
primary key autoincrement,
Description TEXT not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
ProductModelID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
CatalogDescription TEXT,
Instructions TEXT,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
ProductModelID INTEGER not null,
ProductDescriptionID INTEGER not null,
CultureID TEXT not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductModelID, ProductDescriptionID, CultureID),
foreign key (ProductModelID) references ProductModel(ProductModelID),
foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
ProductPhotoID INTEGER
primary key autoincrement,
ThumbNailPhoto BLOB,
ThumbnailPhotoFileName TEXT,
LargePhoto BLOB,
LargePhotoFileName TEXT,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
ProductSubcategoryID INTEGER
primary key autoincrement,
ProductCategoryID INTEGER not null,
Name TEXT not null
unique,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
SalesReasonID INTEGER
primary key autoincrement,
Name TEXT not null,
ReasonType TEXT not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
TerritoryID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
CountryRegionCode TEXT not null,
"Group" TEXT not null,
SalesYTD REAL default 0.0000 not null,
SalesLastYear REAL default 0.0000 not null,
CostYTD REAL default 0.0000 not null,
CostLastYear REAL default 0.0000 not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
BusinessEntityID INTEGER not null
primary key,
TerritoryID INTEGER,
SalesQuota REAL,
Bonus REAL default 0.0000 not null,
CommissionPct REAL default 0.0000 not null,
SalesYTD REAL default 0.0000 not null,
SalesLastYear REAL default 0.0000 not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (BusinessEntityID) references Employee(BusinessEntityID),
foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
BusinessEntityID INTEGER not null,
QuotaDate DATETIME not null,
SalesQuota REAL not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (BusinessEntityID, QuotaDate),
foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
BusinessEntityID INTEGER not null,
TerritoryID INTEGER not null,
StartDate DATETIME not null,
EndDate DATETIME,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (BusinessEntityID, StartDate, TerritoryID),
foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
ScrapReasonID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
ShiftID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
StartTime TEXT not null,
EndTime TEXT not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
ShipMethodID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
ShipBase REAL default 0.0000 not null,
ShipRate REAL default 0.0000 not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
SpecialOfferID INTEGER
primary key autoincrement,
Description TEXT not null,
DiscountPct REAL default 0.0000 not null,
Type TEXT not null,
Category TEXT not null,
StartDate DATETIME not null,
EndDate DATETIME not null,
MinQty INTEGER default 0 not null,
MaxQty INTEGER,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
BusinessEntityID INTEGER not null,
AddressID INTEGER not null,
AddressTypeID INTEGER not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
primary key (BusinessEntityID, AddressID, AddressTypeID),
foreign key (AddressID) references Address(AddressID),
foreign key (AddressTypeID) references AddressType(AddressTypeID),
foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
SalesTaxRateID INTEGER
primary key autoincrement,
StateProvinceID INTEGER not null,
TaxType INTEGER not null,
TaxRate REAL default 0.0000 not null,
Name TEXT not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
unique (StateProvinceID, TaxType),
foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
BusinessEntityID INTEGER not null
primary key,
Name TEXT not null,
SalesPersonID INTEGER,
Demographics TEXT,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
SalesOrderID INTEGER not null,
SalesReasonID INTEGER not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (SalesOrderID, SalesReasonID),
foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
TransactionID INTEGER not null
primary key,
ProductID INTEGER not null,
ReferenceOrderID INTEGER not null,
ReferenceOrderLineID INTEGER default 0 not null,
TransactionDate DATETIME default CURRENT_TIMESTAMP not null,
TransactionType TEXT not null,
Quantity INTEGER not null,
ActualCost REAL not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
UnitMeasureCode TEXT not null
primary key,
Name TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
ProductID INTEGER not null,
StartDate DATE not null,
EndDate DATE,
StandardCost REAL not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductID, StartDate),
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
ProductID INTEGER not null,
DocumentNode TEXT not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductID, DocumentNode),
foreign key (ProductID) references Product(ProductID),
foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
ProductID INTEGER not null,
LocationID INTEGER not null,
Shelf TEXT not null,
Bin INTEGER not null,
Quantity INTEGER default 0 not null,
rowguid TEXT not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductID, LocationID),
foreign key (ProductID) references Product(ProductID),
foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
ProductID INTEGER not null,
ProductPhotoID INTEGER not null,
"Primary" INTEGER default 0 not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductID, ProductPhotoID),
foreign key (ProductID) references Product(ProductID),
foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
ProductReviewID INTEGER
primary key autoincrement,
ProductID INTEGER not null,
ReviewerName TEXT not null,
ReviewDate DATETIME default CURRENT_TIMESTAMP not null,
EmailAddress TEXT not null,
Rating INTEGER not null,
Comments TEXT,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
ShoppingCartItemID INTEGER
primary key autoincrement,
ShoppingCartID TEXT not null,
Quantity INTEGER default 1 not null,
ProductID INTEGER not null,
DateCreated DATETIME default CURRENT_TIMESTAMP not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
SpecialOfferID INTEGER not null,
ProductID INTEGER not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (SpecialOfferID, ProductID),
foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
SalesOrderID INTEGER not null,
SalesOrderDetailID INTEGER
primary key autoincrement,
CarrierTrackingNumber TEXT,
OrderQty INTEGER not null,
ProductID INTEGER not null,
SpecialOfferID INTEGER not null,
UnitPrice REAL not null,
UnitPriceDiscount REAL default 0.0000 not null,
LineTotal REAL not null,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
TransactionID INTEGER
primary key autoincrement,
ProductID INTEGER not null,
ReferenceOrderID INTEGER not null,
ReferenceOrderLineID INTEGER default 0 not null,
TransactionDate DATETIME default CURRENT_TIMESTAMP not null,
TransactionType TEXT not null,
Quantity INTEGER not null,
ActualCost REAL not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
BusinessEntityID INTEGER not null
primary key,
AccountNumber TEXT not null
unique,
Name TEXT not null,
CreditRating INTEGER not null,
PreferredVendorStatus INTEGER default 1 not null,
ActiveFlag INTEGER default 1 not null,
PurchasingWebServiceURL TEXT,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
ProductID INTEGER not null,
BusinessEntityID INTEGER not null,
AverageLeadTime INTEGER not null,
StandardPrice REAL not null,
LastReceiptCost REAL,
LastReceiptDate DATETIME,
MinOrderQty INTEGER not null,
MaxOrderQty INTEGER not null,
OnOrderQty INTEGER,
UnitMeasureCode TEXT not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductID, BusinessEntityID),
foreign key (ProductID) references Product(ProductID),
foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
PurchaseOrderID INTEGER
primary key autoincrement,
RevisionNumber INTEGER default 0 not null,
Status INTEGER default 1 not null,
EmployeeID INTEGER not null,
VendorID INTEGER not null,
ShipMethodID INTEGER not null,
OrderDate DATETIME default CURRENT_TIMESTAMP not null,
ShipDate DATETIME,
SubTotal REAL default 0.0000 not null,
TaxAmt REAL default 0.0000 not null,
Freight REAL default 0.0000 not null,
TotalDue REAL not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (EmployeeID) references Employee(BusinessEntityID),
foreign key (VendorID) references Vendor(BusinessEntityID),
foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
PurchaseOrderID INTEGER not null,
PurchaseOrderDetailID INTEGER
primary key autoincrement,
DueDate DATETIME not null,
OrderQty INTEGER not null,
ProductID INTEGER not null,
UnitPrice REAL not null,
LineTotal REAL not null,
ReceivedQty REAL not null,
RejectedQty REAL not null,
StockedQty REAL not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
WorkOrderID INTEGER
primary key autoincrement,
ProductID INTEGER not null,
OrderQty INTEGER not null,
StockedQty INTEGER not null,
ScrappedQty INTEGER not null,
StartDate DATETIME not null,
EndDate DATETIME,
DueDate DATETIME not null,
ScrapReasonID INTEGER,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
foreign key (ProductID) references Product(ProductID),
foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
WorkOrderID INTEGER not null,
ProductID INTEGER not null,
OperationSequence INTEGER not null,
LocationID INTEGER not null,
ScheduledStartDate DATETIME not null,
ScheduledEndDate DATETIME not null,
ActualStartDate DATETIME,
ActualEndDate DATETIME,
ActualResourceHrs REAL,
PlannedCost REAL not null,
ActualCost REAL,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (WorkOrderID, ProductID, OperationSequence),
foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
CustomerID INTEGER
primary key,
PersonID INTEGER,
StoreID INTEGER,
TerritoryID INTEGER,
AccountNumber TEXT not null
unique,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
foreign key (PersonID) references Person(BusinessEntityID),
foreign key (TerritoryID) references SalesTerritory(TerritoryID),
foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
ProductID INTEGER not null,
StartDate DATE not null,
EndDate DATE,
ListPrice REAL not null,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
primary key (ProductID, StartDate),
foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
AddressID INTEGER
primary key autoincrement,
AddressLine1 TEXT not null,
AddressLine2 TEXT,
City TEXT not null,
StateProvinceID INTEGER not null
references StateProvince,
PostalCode TEXT not null,
SpatialLocation TEXT,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
AddressTypeID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
BillOfMaterialsID INTEGER
primary key autoincrement,
ProductAssemblyID INTEGER
references Product,
ComponentID INTEGER not null
references Product,
StartDate DATETIME default current_timestamp not null,
EndDate DATETIME,
UnitMeasureCode TEXT not null
references UnitMeasure,
BOMLevel INTEGER not null,
PerAssemblyQty REAL default 1.00 not null,
ModifiedDate DATETIME default current_timestamp not null,
unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
BusinessEntityID INTEGER
primary key autoincrement,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
ContactTypeID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
CurrencyRateID INTEGER
primary key autoincrement,
CurrencyRateDate DATETIME not null,
FromCurrencyCode TEXT not null
references Currency,
ToCurrencyCode TEXT not null
references Currency,
AverageRate REAL not null,
EndOfDayRate REAL not null,
ModifiedDate DATETIME default current_timestamp not null,
unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
DepartmentID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
GroupName TEXT not null,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
BusinessEntityID INTEGER not null
references Employee,
DepartmentID INTEGER not null
references Department,
ShiftID INTEGER not null
references Shift,
StartDate DATE not null,
EndDate DATE,
ModifiedDate DATETIME default current_timestamp not null,
primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
BusinessEntityID INTEGER not null
references Employee,
RateChangeDate DATETIME not null,
Rate REAL not null,
PayFrequency INTEGER not null,
ModifiedDate DATETIME default current_timestamp not null,
primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
JobCandidateID INTEGER
primary key autoincrement,
BusinessEntityID INTEGER
references Employee,
Resume TEXT,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
LocationID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
CostRate REAL default 0.0000 not null,
Availability REAL default 0.00 not null,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
PhoneNumberTypeID INTEGER
primary key autoincrement,
Name TEXT not null,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
ProductID INTEGER
primary key autoincrement,
Name TEXT not null
unique,
ProductNumber TEXT not null
unique,
MakeFlag INTEGER default 1 not null,
FinishedGoodsFlag INTEGER default 1 not null,
Color TEXT,
SafetyStockLevel INTEGER not null,
ReorderPoint INTEGER not null,
StandardCost REAL not null,
ListPrice REAL not null,
Size TEXT,
SizeUnitMeasureCode TEXT
references UnitMeasure,
WeightUnitMeasureCode TEXT
references UnitMeasure,
Weight REAL,
DaysToManufacture INTEGER not null,
ProductLine TEXT,
Class TEXT,
Style TEXT,
ProductSubcategoryID INTEGER
references ProductSubcategory,
ProductModelID INTEGER
references ProductModel,
SellStartDate DATETIME not null,
SellEndDate DATETIME,
DiscontinuedDate DATETIME,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
DocumentNode TEXT not null
primary key,
DocumentLevel INTEGER,
Title TEXT not null,
Owner INTEGER not null
references Employee,
FolderFlag INTEGER default 0 not null,
FileName TEXT not null,
FileExtension TEXT not null,
Revision TEXT not null,
ChangeNumber INTEGER default 0 not null,
Status INTEGER not null,
DocumentSummary TEXT,
Document BLOB,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default current_timestamp not null,
unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
StateProvinceID INTEGER
primary key autoincrement,
StateProvinceCode TEXT not null,
CountryRegionCode TEXT not null
references CountryRegion,
IsOnlyStateProvinceFlag INTEGER default 1 not null,
Name TEXT not null
unique,
TerritoryID INTEGER not null
references SalesTerritory,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
CreditCardID INTEGER
primary key autoincrement,
CardType TEXT not null,
CardNumber TEXT not null
unique,
ExpMonth INTEGER not null,
ExpYear INTEGER not null,
ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
SalesOrderID INTEGER
primary key autoincrement,
RevisionNumber INTEGER default 0 not null,
OrderDate DATETIME default CURRENT_TIMESTAMP not null,
DueDate DATETIME not null,
ShipDate DATETIME,
Status INTEGER default 1 not null,
OnlineOrderFlag INTEGER default 1 not null,
SalesOrderNumber TEXT not null
unique,
PurchaseOrderNumber TEXT,
AccountNumber TEXT,
CustomerID INTEGER not null
references Customer,
SalesPersonID INTEGER
references SalesPerson,
TerritoryID INTEGER
references SalesTerritory,
BillToAddressID INTEGER not null
references Address,
ShipToAddressID INTEGER not null
references Address,
ShipMethodID INTEGER not null
references Address,
CreditCardID INTEGER
references CreditCard,
CreditCardApprovalCode TEXT,
CurrencyRateID INTEGER
references CurrencyRate,
SubTotal REAL default 0.0000 not null,
TaxAmt REAL default 0.0000 not null,
Freight REAL default 0.0000 not null,
TotalDue REAL not null,
Comment TEXT,
rowguid TEXT not null
unique,
ModifiedDate DATETIME default CURRENT_TIMESTAMP not null
);
|
language_corpus | How many times does the word "riu" appears in the biwords pair? | riu refers to word = 'riu'; SUM(w1st where wid is word = 'riu' AND w2nd where wid is word = 'riu') | SELECT COUNT(T1.wid) FROM words AS T1 INNER JOIN biwords AS T2 ON T1.wid = T2.w1st INNER JOIN words AS T3 ON T3.wid = T2.w2nd WHERE T1.word = 'riu' | CREATE TABLE langs(lid INTEGER PRIMARY KEY AUTOINCREMENT,
lang TEXT UNIQUE,
locale TEXT UNIQUE,
pages INTEGER DEFAULT 0, -- total pages in this language
words INTEGER DEFAULT 0);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
page INTEGER DEFAULT NULL, -- wikipedia page id
revision INTEGER DEFAULT NULL, -- wikipedia revision page id
title TEXT,
words INTEGER DEFAULT 0, -- number of different words in this page
UNIQUE(lid,page,title));
CREATE TRIGGER ins_page AFTER INSERT ON pages FOR EACH ROW
BEGIN
UPDATE langs SET pages=pages+1 WHERE lid=NEW.lid;
END;
CREATE TRIGGER del_page AFTER DELETE ON pages FOR EACH ROW
BEGIN
UPDATE langs SET pages=pages-1 WHERE lid=OLD.lid;
END;
CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
word TEXT UNIQUE,
occurrences INTEGER DEFAULT 0);
CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
occurrences INTEGER, -- repetitions of this word in this language
PRIMARY KEY(lid,wid))
WITHOUT ROWID;
CREATE TRIGGER ins_lang_word AFTER INSERT ON langs_words FOR EACH ROW
BEGIN
UPDATE langs SET words=words+1 WHERE lid=NEW.lid;
END;
CREATE TRIGGER del_lang_word AFTER DELETE ON langs_words FOR EACH ROW
BEGIN
UPDATE langs SET words=words-1 WHERE lid=OLD.lid;
END;
CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
occurrences INTEGER DEFAULT 0, -- times this word appears into this page
PRIMARY KEY(pid,wid))
WITHOUT ROWID;
CREATE TRIGGER ins_page_word AFTER INSERT ON pages_words FOR EACH ROW
BEGIN
UPDATE pages SET words=words+1 WHERE pid=NEW.pid;
END;
CREATE TRIGGER del_page_word AFTER DELETE ON pages_words FOR EACH ROW
BEGIN
UPDATE pages SET words=words-1 WHERE pid=OLD.pid;
END;
CREATE TABLE biwords(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
w1st INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
w2nd INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
PRIMARY KEY(lid,w1st,w2nd))
WITHOUT ROWID;
|
car_retails | What is the percentage of the payment amount in 2004 was made by Atelier graphique? | DIVIDE(SUM(amount) where customerName = 'Atelier graphique'), (SUM(amount)) as percentage where year(paymentDate) = 2004; | SELECT SUM(CASE WHEN t1.customerName = 'Atelier graphique' THEN t2.amount ELSE 0 END) * 100 / SUM(t2.amount) FROM customers AS t1 INNER JOIN payments AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t2.paymentDate) = '2004' | CREATE TABLE offices
(
officeCode TEXT not null
primary key,
city TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
state TEXT,
country TEXT not null,
postalCode TEXT not null,
territory TEXT not null
);
CREATE TABLE employees
(
employeeNumber INTEGER not null
primary key,
lastName TEXT not null,
firstName TEXT not null,
extension TEXT not null,
email TEXT not null,
officeCode TEXT not null,
reportsTo INTEGER,
jobTitle TEXT not null,
foreign key (officeCode) references offices(officeCode),
foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
customerNumber INTEGER not null
primary key,
customerName TEXT not null,
contactLastName TEXT not null,
contactFirstName TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
city TEXT not null,
state TEXT,
postalCode TEXT,
country TEXT not null,
salesRepEmployeeNumber INTEGER,
creditLimit REAL,
foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
orderNumber INTEGER not null
primary key,
orderDate DATE not null,
requiredDate DATE not null,
shippedDate DATE,
status TEXT not null,
comments TEXT,
customerNumber INTEGER not null,
foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
customerNumber INTEGER not null,
checkNumber TEXT not null,
paymentDate DATE not null,
amount REAL not null,
primary key (customerNumber, checkNumber),
foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
productLine TEXT not null
primary key,
textDescription TEXT,
htmlDescription TEXT,
image BLOB
);
CREATE TABLE products
(
productCode TEXT not null
primary key,
productName TEXT not null,
productLine TEXT not null,
productScale TEXT not null,
productVendor TEXT not null,
productDescription TEXT not null,
quantityInStock INTEGER not null,
buyPrice REAL not null,
MSRP REAL not null,
foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
orderNumber INTEGER not null
references orders,
productCode TEXT not null
references products,
quantityOrdered INTEGER not null,
priceEach REAL not null,
orderLineNumber INTEGER not null,
primary key (orderNumber, productCode)
);
|
movie_3 | How many times is the number of films Gina DeGeneres acted in than Penelope Guinness? | "Gina DeGeneres" and "Penelope Guinness" are both full name of actor; times number of film = Divide (Count (film_id where first_name = 'GINA' and last_name = 'DEGENERES'), Count(film_id where first_name = 'PENELOPE' and last_name = 'GUINESS')) | SELECT CAST(SUM(IIF(T2.first_name = 'GINA' AND T2.last_name = 'DEGENERES', 1, 0)) AS REAL) * 100 / SUM(IIF(T2.first_name = 'PENELOPE' AND T2.last_name = 'GUINESS', 1, 0)) FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id | CREATE TABLE film_text
(
film_id INTEGER not null
primary key,
title TEXT not null,
description TEXT null
);
CREATE TABLE IF NOT EXISTS "actor"
(
actor_id INTEGER
primary key autoincrement,
first_name TEXT not null,
last_name TEXT not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "address"
(
address_id INTEGER
primary key autoincrement,
address TEXT not null,
address2 TEXT,
district TEXT not null,
city_id INTEGER not null
references city
on update cascade,
postal_code TEXT,
phone TEXT not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "category"
(
category_id INTEGER
primary key autoincrement,
name TEXT not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "city"
(
city_id INTEGER
primary key autoincrement,
city TEXT not null,
country_id INTEGER not null
references country
on update cascade,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "country"
(
country_id INTEGER
primary key autoincrement,
country TEXT not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "customer"
(
customer_id INTEGER
primary key autoincrement,
store_id INTEGER not null
references store
on update cascade,
first_name TEXT not null,
last_name TEXT not null,
email TEXT,
address_id INTEGER not null
references address
on update cascade,
active INTEGER default 1 not null,
create_date DATETIME not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "film"
(
film_id INTEGER
primary key autoincrement,
title TEXT not null,
description TEXT,
release_year TEXT,
language_id INTEGER not null
references language
on update cascade,
original_language_id INTEGER
references language
on update cascade,
rental_duration INTEGER default 3 not null,
rental_rate REAL default 4.99 not null,
length INTEGER,
replacement_cost REAL default 19.99 not null,
rating TEXT default 'G',
special_features TEXT,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "film_actor"
(
actor_id INTEGER not null
references actor
on update cascade,
film_id INTEGER not null
references film
on update cascade,
last_update DATETIME default CURRENT_TIMESTAMP not null,
primary key (actor_id, film_id)
);
CREATE TABLE IF NOT EXISTS "film_category"
(
film_id INTEGER not null
references film
on update cascade,
category_id INTEGER not null
references category
on update cascade,
last_update DATETIME default CURRENT_TIMESTAMP not null,
primary key (film_id, category_id)
);
CREATE TABLE IF NOT EXISTS "inventory"
(
inventory_id INTEGER
primary key autoincrement,
film_id INTEGER not null
references film
on update cascade,
store_id INTEGER not null
references store
on update cascade,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "language"
(
language_id INTEGER
primary key autoincrement,
name TEXT not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "payment"
(
payment_id INTEGER
primary key autoincrement,
customer_id INTEGER not null
references customer
on update cascade,
staff_id INTEGER not null
references staff
on update cascade,
rental_id INTEGER
references rental
on update cascade on delete set null,
amount REAL not null,
payment_date DATETIME not null,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "rental"
(
rental_id INTEGER
primary key autoincrement,
rental_date DATETIME not null,
inventory_id INTEGER not null
references inventory
on update cascade,
customer_id INTEGER not null
references customer
on update cascade,
return_date DATETIME,
staff_id INTEGER not null
references staff
on update cascade,
last_update DATETIME default CURRENT_TIMESTAMP not null,
unique (rental_date, inventory_id, customer_id)
);
CREATE TABLE IF NOT EXISTS "staff"
(
staff_id INTEGER
primary key autoincrement,
first_name TEXT not null,
last_name TEXT not null,
address_id INTEGER not null
references address
on update cascade,
picture BLOB,
email TEXT,
store_id INTEGER not null
references store
on update cascade,
active INTEGER default 1 not null,
username TEXT not null,
password TEXT,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "store"
(
store_id INTEGER
primary key autoincrement,
manager_staff_id INTEGER not null
unique
references staff
on update cascade,
address_id INTEGER not null
references address
on update cascade,
last_update DATETIME default CURRENT_TIMESTAMP not null
);
|
hockey | What is the total amount of assists of the NHL player with the most assists in history? Please indicate his/her full name. | NHL refers to lgID = 'NHL'; most assists refers to max(A); full name = nameGiven + lastName; total amount of assists = sum(A(playerID(max(A)))) | SELECT SUM(T1.A), T2.firstName, T2.lastName FROM Scoring AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.lgID = 'NHL' GROUP BY T2.firstName, T2.lastName ORDER BY SUM(T1.A) DESC LIMIT 1 | CREATE TABLE AwardsMisc
(
name TEXT not null
primary key,
ID TEXT,
award TEXT,
year INTEGER,
lgID TEXT,
note TEXT
);
CREATE TABLE HOF
(
year INTEGER,
hofID TEXT not null
primary key,
name TEXT,
category TEXT
);
CREATE TABLE Teams
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
franchID TEXT,
confID TEXT,
divID TEXT,
rank INTEGER,
playoff TEXT,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
OTL TEXT,
Pts INTEGER,
SoW TEXT,
SoL TEXT,
GF INTEGER,
GA INTEGER,
name TEXT,
PIM TEXT,
BenchMinor TEXT,
PPG TEXT,
PPC TEXT,
SHA TEXT,
PKG TEXT,
PKC TEXT,
SHF TEXT,
primary key (year, tmID)
);
CREATE TABLE Coaches
(
coachID TEXT not null,
year INTEGER not null,
tmID TEXT not null,
lgID TEXT,
stint INTEGER not null,
notes TEXT,
g INTEGER,
w INTEGER,
l INTEGER,
t INTEGER,
postg TEXT,
postw TEXT,
postl TEXT,
postt TEXT,
primary key (coachID, year, tmID, stint),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE AwardsCoaches
(
coachID TEXT,
award TEXT,
year INTEGER,
lgID TEXT,
note TEXT,
foreign key (coachID) references Coaches (coachID)
);
CREATE TABLE Master
(
playerID TEXT,
coachID TEXT,
hofID TEXT,
firstName TEXT,
lastName TEXT not null,
nameNote TEXT,
nameGiven TEXT,
nameNick TEXT,
height TEXT,
weight TEXT,
shootCatch TEXT,
legendsID TEXT,
ihdbID TEXT,
hrefID TEXT,
firstNHL TEXT,
lastNHL TEXT,
firstWHA TEXT,
lastWHA TEXT,
pos TEXT,
birthYear TEXT,
birthMon TEXT,
birthDay TEXT,
birthCountry TEXT,
birthState TEXT,
birthCity TEXT,
deathYear TEXT,
deathMon TEXT,
deathDay TEXT,
deathCountry TEXT,
deathState TEXT,
deathCity TEXT,
foreign key (coachID) references Coaches (coachID)
on update cascade on delete cascade
);
CREATE TABLE AwardsPlayers
(
playerID TEXT not null,
award TEXT not null,
year INTEGER not null,
lgID TEXT,
note TEXT,
pos TEXT,
primary key (playerID, award, year),
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE CombinedShutouts
(
year INTEGER,
month INTEGER,
date INTEGER,
tmID TEXT,
oppID TEXT,
"R/P" TEXT,
IDgoalie1 TEXT,
IDgoalie2 TEXT,
foreign key (IDgoalie1) references Master (playerID)
on update cascade on delete cascade,
foreign key (IDgoalie2) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE Goalies
(
playerID TEXT not null,
year INTEGER not null,
stint INTEGER not null,
tmID TEXT,
lgID TEXT,
GP TEXT,
Min TEXT,
W TEXT,
L TEXT,
"T/OL" TEXT,
ENG TEXT,
SHO TEXT,
GA TEXT,
SA TEXT,
PostGP TEXT,
PostMin TEXT,
PostW TEXT,
PostL TEXT,
PostT TEXT,
PostENG TEXT,
PostSHO TEXT,
PostGA TEXT,
PostSA TEXT,
primary key (playerID, year, stint),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE GoaliesSC
(
playerID TEXT not null,
year INTEGER not null,
tmID TEXT,
lgID TEXT,
GP INTEGER,
Min INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
SHO INTEGER,
GA INTEGER,
primary key (playerID, year),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE GoaliesShootout
(
playerID TEXT,
year INTEGER,
stint INTEGER,
tmID TEXT,
W INTEGER,
L INTEGER,
SA INTEGER,
GA INTEGER,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE Scoring
(
playerID TEXT,
year INTEGER,
stint INTEGER,
tmID TEXT,
lgID TEXT,
pos TEXT,
GP INTEGER,
G INTEGER,
A INTEGER,
Pts INTEGER,
PIM INTEGER,
"+/-" TEXT,
PPG TEXT,
PPA TEXT,
SHG TEXT,
SHA TEXT,
GWG TEXT,
GTG TEXT,
SOG TEXT,
PostGP TEXT,
PostG TEXT,
PostA TEXT,
PostPts TEXT,
PostPIM TEXT,
"Post+/-" TEXT,
PostPPG TEXT,
PostPPA TEXT,
PostSHG TEXT,
PostSHA TEXT,
PostGWG TEXT,
PostSOG TEXT,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE ScoringSC
(
playerID TEXT,
year INTEGER,
tmID TEXT,
lgID TEXT,
pos TEXT,
GP INTEGER,
G INTEGER,
A INTEGER,
Pts INTEGER,
PIM INTEGER,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE ScoringShootout
(
playerID TEXT,
year INTEGER,
stint INTEGER,
tmID TEXT,
S INTEGER,
G INTEGER,
GDG INTEGER,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE ScoringSup
(
playerID TEXT,
year INTEGER,
PPA TEXT,
SHA TEXT,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE SeriesPost
(
year INTEGER,
round TEXT,
series TEXT,
tmIDWinner TEXT,
lgIDWinner TEXT,
tmIDLoser TEXT,
lgIDLoser TEXT,
W INTEGER,
L INTEGER,
T INTEGER,
GoalsWinner INTEGER,
GoalsLoser INTEGER,
note TEXT,
foreign key (year, tmIDWinner) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (year, tmIDLoser) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE TeamSplits
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
hW INTEGER,
hL INTEGER,
hT INTEGER,
hOTL TEXT,
rW INTEGER,
rL INTEGER,
rT INTEGER,
rOTL TEXT,
SepW TEXT,
SepL TEXT,
SepT TEXT,
SepOL TEXT,
OctW TEXT,
OctL TEXT,
OctT TEXT,
OctOL TEXT,
NovW TEXT,
NovL TEXT,
NovT TEXT,
NovOL TEXT,
DecW TEXT,
DecL TEXT,
DecT TEXT,
DecOL TEXT,
JanW INTEGER,
JanL INTEGER,
JanT INTEGER,
JanOL TEXT,
FebW INTEGER,
FebL INTEGER,
FebT INTEGER,
FebOL TEXT,
MarW TEXT,
MarL TEXT,
MarT TEXT,
MarOL TEXT,
AprW TEXT,
AprL TEXT,
AprT TEXT,
AprOL TEXT,
primary key (year, tmID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE TeamVsTeam
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
oppID TEXT not null,
W INTEGER,
L INTEGER,
T INTEGER,
OTL TEXT,
primary key (year, tmID, oppID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (oppID, year) references Teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE TeamsHalf
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
half INTEGER not null,
rank INTEGER,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
GF INTEGER,
GA INTEGER,
primary key (year, tmID, half),
foreign key (tmID, year) references Teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE TeamsPost
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
GF INTEGER,
GA INTEGER,
PIM TEXT,
BenchMinor TEXT,
PPG TEXT,
PPC TEXT,
SHA TEXT,
PKG TEXT,
PKC TEXT,
SHF TEXT,
primary key (year, tmID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE TeamsSC
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
GF INTEGER,
GA INTEGER,
PIM TEXT,
primary key (year, tmID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE abbrev
(
Type TEXT not null,
Code TEXT not null,
Fullname TEXT,
primary key (Type, Code)
);
|
sales | Identify the name of the sales person with employee ID 7. | name of the sales person = FirstName, MiddleInitial, LastName; | SELECT FirstName, MiddleInitial, LastName FROM Employees WHERE EmployeeID = 7 | CREATE TABLE Customers
(
CustomerID INTEGER not null
primary key,
FirstName TEXT not null,
MiddleInitial TEXT null,
LastName TEXT not null
);
CREATE TABLE Employees
(
EmployeeID INTEGER not null
primary key,
FirstName TEXT not null,
MiddleInitial TEXT null,
LastName TEXT not null
);
CREATE TABLE Products
(
ProductID INTEGER not null
primary key,
Name TEXT not null,
Price REAL null
);
CREATE TABLE Sales
(
SalesID INTEGER not null
primary key,
SalesPersonID INTEGER not null,
CustomerID INTEGER not null,
ProductID INTEGER not null,
Quantity INTEGER not null,
foreign key (SalesPersonID) references Employees (EmployeeID)
on update cascade on delete cascade,
foreign key (CustomerID) references Customers (CustomerID)
on update cascade on delete cascade,
foreign key (ProductID) references Products (ProductID)
on update cascade on delete cascade
);
|
talkingdata | On which brand of phone are the most applications installed? | brand of phone refers to phone_brand; most applications are installed refers to MAX(COUNT(is_installed = 1)); | SELECT T.phone_brand FROM ( SELECT T1.phone_brand, COUNT(T4.is_active) AS num FROM phone_brand_device_model2 AS T1 INNER JOIN gender_age AS T2 ON T1.device_id = T2.device_id INNER JOIN events_relevant AS T3 ON T2.device_id = T3.device_id INNER JOIN app_events_relevant AS T4 ON T3.event_id = T4.event_id WHERE T4.is_active = 1 GROUP BY T1.phone_brand ) AS T ORDER BY T.num DESC LIMIT 1 | CREATE TABLE `app_all`
(
`app_id` INTEGER NOT NULL,
PRIMARY KEY (`app_id`)
);
CREATE TABLE `app_events` (
`event_id` INTEGER NOT NULL,
`app_id` INTEGER NOT NULL,
`is_installed` INTEGER NOT NULL,
`is_active` INTEGER NOT NULL,
PRIMARY KEY (`event_id`,`app_id`),
FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `app_events_relevant` (
`event_id` INTEGER NOT NULL,
`app_id` INTEGER NOT NULL,
`is_installed` INTEGER DEFAULT NULL,
`is_active` INTEGER DEFAULT NULL,
PRIMARY KEY (`event_id`,`app_id`),
FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `app_labels` (
`app_id` INTEGER NOT NULL,
`label_id` INTEGER NOT NULL,
FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `events` (
`event_id` INTEGER NOT NULL,
`device_id` INTEGER DEFAULT NULL,
`timestamp` DATETIME DEFAULT NULL,
`longitude` REAL DEFAULT NULL,
`latitude` REAL DEFAULT NULL,
PRIMARY KEY (`event_id`)
);
CREATE TABLE `events_relevant` (
`event_id` INTEGER NOT NULL,
`device_id` INTEGER DEFAULT NULL,
`timestamp` DATETIME NOT NULL,
`longitude` REAL NOT NULL,
`latitude` REAL NOT NULL,
PRIMARY KEY (`event_id`),
FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `gender_age` (
`device_id` INTEGER NOT NULL,
`gender` TEXT DEFAULT NULL,
`age` INTEGER DEFAULT NULL,
`group` TEXT DEFAULT NULL,
PRIMARY KEY (`device_id`),
FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `gender_age_test` (
`device_id` INTEGER NOT NULL,
PRIMARY KEY (`device_id`)
);
CREATE TABLE `gender_age_train` (
`device_id` INTEGER NOT NULL,
`gender` TEXT DEFAULT NULL,
`age` INTEGER DEFAULT NULL,
`group` TEXT DEFAULT NULL,
PRIMARY KEY (`device_id`)
);
CREATE TABLE `label_categories` (
`label_id` INTEGER NOT NULL,
`category` TEXT DEFAULT NULL,
PRIMARY KEY (`label_id`)
);
CREATE TABLE `phone_brand_device_model2` (
`device_id` INTEGER NOT NULL,
`phone_brand` TEXT NOT NULL,
`device_model` TEXT NOT NULL,
PRIMARY KEY (`device_id`,`phone_brand`,`device_model`)
);
CREATE TABLE `sample_submission` (
`device_id` INTEGER NOT NULL,
`F23-` REAL DEFAULT NULL,
`F24-26` REAL DEFAULT NULL,
`F27-28` REAL DEFAULT NULL,
`F29-32` REAL DEFAULT NULL,
`F33-42` REAL DEFAULT NULL,
`F43+` REAL DEFAULT NULL,
`M22-` REAL DEFAULT NULL,
`M23-26` REAL DEFAULT NULL,
`M27-28` REAL DEFAULT NULL,
`M29-31` REAL DEFAULT NULL,
`M32-38` REAL DEFAULT NULL,
`M39+` REAL DEFAULT NULL,
PRIMARY KEY (`device_id`)
);
|
car_retails | For the productline where the product No.S18_2949 was produced, what's the text description for that product line? | SELECT t1.textDescription FROM productlines AS t1 INNER JOIN products AS t2 ON t1.productLine = t2.productLine WHERE t2.productCode = 'S18_2949' | CREATE TABLE offices
(
officeCode TEXT not null
primary key,
city TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
state TEXT,
country TEXT not null,
postalCode TEXT not null,
territory TEXT not null
);
CREATE TABLE employees
(
employeeNumber INTEGER not null
primary key,
lastName TEXT not null,
firstName TEXT not null,
extension TEXT not null,
email TEXT not null,
officeCode TEXT not null,
reportsTo INTEGER,
jobTitle TEXT not null,
foreign key (officeCode) references offices(officeCode),
foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
customerNumber INTEGER not null
primary key,
customerName TEXT not null,
contactLastName TEXT not null,
contactFirstName TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
city TEXT not null,
state TEXT,
postalCode TEXT,
country TEXT not null,
salesRepEmployeeNumber INTEGER,
creditLimit REAL,
foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
orderNumber INTEGER not null
primary key,
orderDate DATE not null,
requiredDate DATE not null,
shippedDate DATE,
status TEXT not null,
comments TEXT,
customerNumber INTEGER not null,
foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
customerNumber INTEGER not null,
checkNumber TEXT not null,
paymentDate DATE not null,
amount REAL not null,
primary key (customerNumber, checkNumber),
foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
productLine TEXT not null
primary key,
textDescription TEXT,
htmlDescription TEXT,
image BLOB
);
CREATE TABLE products
(
productCode TEXT not null
primary key,
productName TEXT not null,
productLine TEXT not null,
productScale TEXT not null,
productVendor TEXT not null,
productDescription TEXT not null,
quantityInStock INTEGER not null,
buyPrice REAL not null,
MSRP REAL not null,
foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
orderNumber INTEGER not null
references orders,
productCode TEXT not null
references products,
quantityOrdered INTEGER not null,
priceEach REAL not null,
orderLineNumber INTEGER not null,
primary key (orderNumber, productCode)
);
|
|
olympics | Among the males, list the region name of people with height greater than 87% of the average height of all people listed. | males refer to gender = 'M'; height greater than 87% of the average height refers to height > MULTIPLY(AVG(height), 0.87); | SELECT DISTINCT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.gender = 'M' AND T3.height * 100 > ( SELECT AVG(height) FROM person WHERE gender = 'M' ) * 87 | CREATE TABLE city
(
id INTEGER not null
primary key,
city_name TEXT default NULL
);
CREATE TABLE games
(
id INTEGER not null
primary key,
games_year INTEGER default NULL,
games_name TEXT default NULL,
season TEXT default NULL
);
CREATE TABLE games_city
(
games_id INTEGER default NULL,
city_id INTEGER default NULL,
foreign key (city_id) references city(id),
foreign key (games_id) references games(id)
);
CREATE TABLE medal
(
id INTEGER not null
primary key,
medal_name TEXT default NULL
);
CREATE TABLE noc_region
(
id INTEGER not null
primary key,
noc TEXT default NULL,
region_name TEXT default NULL
);
CREATE TABLE person
(
id INTEGER not null
primary key,
full_name TEXT default NULL,
gender TEXT default NULL,
height INTEGER default NULL,
weight INTEGER default NULL
);
CREATE TABLE games_competitor
(
id INTEGER not null
primary key,
games_id INTEGER default NULL,
person_id INTEGER default NULL,
age INTEGER default NULL,
foreign key (games_id) references games(id),
foreign key (person_id) references person(id)
);
CREATE TABLE person_region
(
person_id INTEGER default NULL,
region_id INTEGER default NULL,
foreign key (person_id) references person(id),
foreign key (region_id) references noc_region(id)
);
CREATE TABLE sport
(
id INTEGER not null
primary key,
sport_name TEXT default NULL
);
CREATE TABLE event
(
id INTEGER not null
primary key,
sport_id INTEGER default NULL,
event_name TEXT default NULL,
foreign key (sport_id) references sport(id)
);
CREATE TABLE competitor_event
(
event_id INTEGER default NULL,
competitor_id INTEGER default NULL,
medal_id INTEGER default NULL,
foreign key (competitor_id) references games_competitor(id),
foreign key (event_id) references event(id),
foreign key (medal_id) references medal(id)
);
|
superstore | List the name of all products in the west superstore that customers chose for same-day shipment in the year 2013. | name of all products refers to Product Name; same-day shipment refers to "Ship Mode" = 'Same Day'; year 2013 refers to "Ship Date" BETWEEN '2013-01-01' AND '2013-12-31' | SELECT T2.`Product Name` FROM west_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Ship Mode` = 'Same Day' AND T1.`Ship Date` LIKE '2013%' | CREATE TABLE people
(
"Customer ID" TEXT,
"Customer Name" TEXT,
Segment TEXT,
Country TEXT,
City TEXT,
State TEXT,
"Postal Code" INTEGER,
Region TEXT,
primary key ("Customer ID", Region)
);
CREATE TABLE product
(
"Product ID" TEXT,
"Product Name" TEXT,
Category TEXT,
"Sub-Category" TEXT,
Region TEXT,
primary key ("Product ID", Region)
);
CREATE TABLE central_superstore
(
"Row ID" INTEGER
primary key,
"Order ID" TEXT,
"Order Date" DATE,
"Ship Date" DATE,
"Ship Mode" TEXT,
"Customer ID" TEXT,
Region TEXT,
"Product ID" TEXT,
Sales REAL,
Quantity INTEGER,
Discount REAL,
Profit REAL,
foreign key ("Customer ID", Region) references people("Customer ID",Region),
foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE east_superstore
(
"Row ID" INTEGER
primary key,
"Order ID" TEXT,
"Order Date" DATE,
"Ship Date" DATE,
"Ship Mode" TEXT,
"Customer ID" TEXT,
Region TEXT,
"Product ID" TEXT,
Sales REAL,
Quantity INTEGER,
Discount REAL,
Profit REAL,
foreign key ("Customer ID", Region) references people("Customer ID",Region),
foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE south_superstore
(
"Row ID" INTEGER
primary key,
"Order ID" TEXT,
"Order Date" DATE,
"Ship Date" DATE,
"Ship Mode" TEXT,
"Customer ID" TEXT,
Region TEXT,
"Product ID" TEXT,
Sales REAL,
Quantity INTEGER,
Discount REAL,
Profit REAL,
foreign key ("Customer ID", Region) references people("Customer ID",Region),
foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE west_superstore
(
"Row ID" INTEGER
primary key,
"Order ID" TEXT,
"Order Date" DATE,
"Ship Date" DATE,
"Ship Mode" TEXT,
"Customer ID" TEXT,
Region TEXT,
"Product ID" TEXT,
Sales REAL,
Quantity INTEGER,
Discount REAL,
Profit REAL,
foreign key ("Customer ID", Region) references people("Customer ID",Region),
foreign key ("Product ID", Region) references product("Product ID",Region)
);
|
chicago_crime | How many crime against society were reported in Englewood? | "Englewood" is the community_area_name; 'Society' is the crime_against | SELECT SUM(CASE WHEN T3.community_area_name = 'Englewood' THEN 1 ELSE 0 END) FROM FBI_Code AS T1 INNER JOIN Crime AS T2 ON T1.fbi_code_no = T2.fbi_code_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.crime_against = 'Society' | CREATE TABLE Community_Area
(
community_area_no INTEGER
primary key,
community_area_name TEXT,
side TEXT,
population TEXT
);
CREATE TABLE District
(
district_no INTEGER
primary key,
district_name TEXT,
address TEXT,
zip_code INTEGER,
commander TEXT,
email TEXT,
phone TEXT,
fax TEXT,
tty TEXT,
twitter TEXT
);
CREATE TABLE FBI_Code
(
fbi_code_no TEXT
primary key,
title TEXT,
description TEXT,
crime_against TEXT
);
CREATE TABLE IUCR
(
iucr_no TEXT
primary key,
primary_description TEXT,
secondary_description TEXT,
index_code TEXT
);
CREATE TABLE Neighborhood
(
neighborhood_name TEXT
primary key,
community_area_no INTEGER,
foreign key (community_area_no) references Community_Area(community_area_no)
);
CREATE TABLE Ward
(
ward_no INTEGER
primary key,
alderman_first_name TEXT,
alderman_last_name TEXT,
alderman_name_suffix TEXT,
ward_office_address TEXT,
ward_office_zip TEXT,
ward_email TEXT,
ward_office_phone TEXT,
ward_office_fax TEXT,
city_hall_office_room INTEGER,
city_hall_office_phone TEXT,
city_hall_office_fax TEXT,
Population INTEGER
);
CREATE TABLE Crime
(
report_no INTEGER
primary key,
case_number TEXT,
date TEXT,
block TEXT,
iucr_no TEXT,
location_description TEXT,
arrest TEXT,
domestic TEXT,
beat INTEGER,
district_no INTEGER,
ward_no INTEGER,
community_area_no INTEGER,
fbi_code_no TEXT,
latitude TEXT,
longitude TEXT,
foreign key (ward_no) references Ward(ward_no),
foreign key (iucr_no) references IUCR(iucr_no),
foreign key (district_no) references District(district_no),
foreign key (community_area_no) references Community_Area(community_area_no),
foreign key (fbi_code_no) references FBI_Code(fbi_code_no)
);
|
public_review_platform | How many businesses are opened the same number of hours every day of the week? | how much time does this business open refers to SUBTRACT(closing_time, opening_time); every day of the week refers to day_id BETWEEN 1 AND 7 | SELECT COUNT(business_id) FROM Business_Hours WHERE opening_time = '8AM' AND closing_time = '6PM' | CREATE TABLE Attributes
(
attribute_id INTEGER
constraint Attributes_pk
primary key,
attribute_name TEXT
);
CREATE TABLE Categories
(
category_id INTEGER
constraint Categories_pk
primary key,
category_name TEXT
);
CREATE TABLE Compliments
(
compliment_id INTEGER
constraint Compliments_pk
primary key,
compliment_type TEXT
);
CREATE TABLE Days
(
day_id INTEGER
constraint Days_pk
primary key,
day_of_week TEXT
);
CREATE TABLE Years
(
year_id INTEGER
constraint Years_pk
primary key,
actual_year INTEGER
);
CREATE TABLE IF NOT EXISTS "Business_Attributes"
(
attribute_id INTEGER
constraint Business_Attributes_Attributes_attribute_id_fk
references Attributes,
business_id INTEGER
constraint Business_Attributes_Business_business_id_fk
references Business,
attribute_value TEXT,
constraint Business_Attributes_pk
primary key (attribute_id, business_id)
);
CREATE TABLE IF NOT EXISTS "Business_Categories"
(
business_id INTEGER
constraint Business_Categories_Business_business_id_fk
references Business,
category_id INTEGER
constraint Business_Categories_Categories_category_id_fk
references Categories,
constraint Business_Categories_pk
primary key (business_id, category_id)
);
CREATE TABLE IF NOT EXISTS "Business_Hours"
(
business_id INTEGER
constraint Business_Hours_Business_business_id_fk
references Business,
day_id INTEGER
constraint Business_Hours_Days_day_id_fk
references Days,
opening_time TEXT,
closing_time TEXT,
constraint Business_Hours_pk
primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Checkins"
(
business_id INTEGER
constraint Checkins_Business_business_id_fk
references Business,
day_id INTEGER
constraint Checkins_Days_day_id_fk
references Days,
label_time_0 TEXT,
label_time_1 TEXT,
label_time_2 TEXT,
label_time_3 TEXT,
label_time_4 TEXT,
label_time_5 TEXT,
label_time_6 TEXT,
label_time_7 TEXT,
label_time_8 TEXT,
label_time_9 TEXT,
label_time_10 TEXT,
label_time_11 TEXT,
label_time_12 TEXT,
label_time_13 TEXT,
label_time_14 TEXT,
label_time_15 TEXT,
label_time_16 TEXT,
label_time_17 TEXT,
label_time_18 TEXT,
label_time_19 TEXT,
label_time_20 TEXT,
label_time_21 TEXT,
label_time_22 TEXT,
label_time_23 TEXT,
constraint Checkins_pk
primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Elite"
(
user_id INTEGER
constraint Elite_Users_user_id_fk
references Users,
year_id INTEGER
constraint Elite_Years_year_id_fk
references Years,
constraint Elite_pk
primary key (user_id, year_id)
);
CREATE TABLE IF NOT EXISTS "Reviews"
(
business_id INTEGER
constraint Reviews_Business_business_id_fk
references Business,
user_id INTEGER
constraint Reviews_Users_user_id_fk
references Users,
review_stars INTEGER,
review_votes_funny TEXT,
review_votes_useful TEXT,
review_votes_cool TEXT,
review_length TEXT,
constraint Reviews_pk
primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Tips"
(
business_id INTEGER
constraint Tips_Business_business_id_fk
references Business,
user_id INTEGER
constraint Tips_Users_user_id_fk
references Users,
likes INTEGER,
tip_length TEXT,
constraint Tips_pk
primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Users_Compliments"
(
compliment_id INTEGER
constraint Users_Compliments_Compliments_compliment_id_fk
references Compliments,
user_id INTEGER
constraint Users_Compliments_Users_user_id_fk
references Users,
number_of_compliments TEXT,
constraint Users_Compliments_pk
primary key (compliment_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Business"
(
business_id INTEGER
constraint Business_pk
primary key,
active TEXT,
city TEXT,
state TEXT,
stars REAL,
review_count TEXT
);
CREATE TABLE IF NOT EXISTS "Users"
(
user_id INTEGER
constraint Users_pk
primary key,
user_yelping_since_year INTEGER,
user_average_stars TEXT,
user_votes_funny TEXT,
user_votes_useful TEXT,
user_votes_cool TEXT,
user_review_count TEXT,
user_fans TEXT
);
|
car_retails | Of all the classic cars, with a product scale of 1:18, which product is the most ordered product by customers? | classic car is a product line; most ordered product refers to MAX(quantityOrdered); | SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productScale = '1:18' AND T1.productLine = 'Classic Cars' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1 | CREATE TABLE offices
(
officeCode TEXT not null
primary key,
city TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
state TEXT,
country TEXT not null,
postalCode TEXT not null,
territory TEXT not null
);
CREATE TABLE employees
(
employeeNumber INTEGER not null
primary key,
lastName TEXT not null,
firstName TEXT not null,
extension TEXT not null,
email TEXT not null,
officeCode TEXT not null,
reportsTo INTEGER,
jobTitle TEXT not null,
foreign key (officeCode) references offices(officeCode),
foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
customerNumber INTEGER not null
primary key,
customerName TEXT not null,
contactLastName TEXT not null,
contactFirstName TEXT not null,
phone TEXT not null,
addressLine1 TEXT not null,
addressLine2 TEXT,
city TEXT not null,
state TEXT,
postalCode TEXT,
country TEXT not null,
salesRepEmployeeNumber INTEGER,
creditLimit REAL,
foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
orderNumber INTEGER not null
primary key,
orderDate DATE not null,
requiredDate DATE not null,
shippedDate DATE,
status TEXT not null,
comments TEXT,
customerNumber INTEGER not null,
foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
customerNumber INTEGER not null,
checkNumber TEXT not null,
paymentDate DATE not null,
amount REAL not null,
primary key (customerNumber, checkNumber),
foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
productLine TEXT not null
primary key,
textDescription TEXT,
htmlDescription TEXT,
image BLOB
);
CREATE TABLE products
(
productCode TEXT not null
primary key,
productName TEXT not null,
productLine TEXT not null,
productScale TEXT not null,
productVendor TEXT not null,
productDescription TEXT not null,
quantityInStock INTEGER not null,
buyPrice REAL not null,
MSRP REAL not null,
foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
orderNumber INTEGER not null
references orders,
productCode TEXT not null
references products,
quantityOrdered INTEGER not null,
priceEach REAL not null,
orderLineNumber INTEGER not null,
primary key (orderNumber, productCode)
);
|
movielens | Among the films directed by directors who direct the best, how many of them have an average rating of over 3.5? | d_quality = 5 refers to direct the best, d_quality = 0 refers to direct the worst | SELECT COUNT(*) FROM ( SELECT DISTINCT T2.movieid FROM directors AS T1 INNER JOIN movies2directors AS T2 ON T1.directorid = T2.directorid INNER JOIN u2base AS T3 ON T2.movieid = T3.movieid WHERE T1.d_quality = 5 GROUP BY T2.movieid HAVING AVG(T3.rating) > 3.5 ) AS T1 | CREATE TABLE users
(
userid INTEGER default 0 not null
primary key,
age TEXT not null,
u_gender TEXT not null,
occupation TEXT not null
);
CREATE TABLE IF NOT EXISTS "directors"
(
directorid INTEGER not null
primary key,
d_quality INTEGER not null,
avg_revenue INTEGER not null
);
CREATE INDEX avg_revenue
on directors (avg_revenue);
CREATE INDEX d_quality
on directors (d_quality);
CREATE TABLE IF NOT EXISTS "actors"
(
actorid INTEGER not null
primary key,
a_gender TEXT not null,
a_quality INTEGER not null
);
CREATE TABLE IF NOT EXISTS "movies"
(
movieid INTEGER default 0 not null
primary key,
year INTEGER not null,
isEnglish TEXT not null,
country TEXT not null,
runningtime INTEGER not null
);
CREATE TABLE IF NOT EXISTS "movies2actors"
(
movieid INTEGER not null
references movies
on update cascade on delete cascade,
actorid INTEGER not null
references actors
on update cascade on delete cascade,
cast_num INTEGER not null,
primary key (movieid, actorid)
);
CREATE TABLE IF NOT EXISTS "movies2directors"
(
movieid INTEGER not null
references movies
on update cascade on delete cascade,
directorid INTEGER not null
references directors
on update cascade on delete cascade,
genre TEXT not null,
primary key (movieid, directorid)
);
CREATE TABLE IF NOT EXISTS "u2base"
(
userid INTEGER default 0 not null
references users
on update cascade on delete cascade,
movieid INTEGER not null
references movies
on update cascade on delete cascade,
rating TEXT not null,
primary key (userid, movieid)
);
|
mental_health_survey | How many respondents who participated in the survey in 2014 work remotely at least 50% of the time? | respondents' and 'users' are synonyms; work remotely at least 50% of the time refers to AnswerText(SurveyID = 2014& QuestionID = 93) = 'Yes' | SELECT COUNT(T1.AnswerText) FROM Answer AS T1 INNER JOIN Question AS T2 ON T1.QuestionID = T2.questionid WHERE T1.QuestionID = 93 AND T1.SurveyID = 2014 AND T1.AnswerText = 'Yes' | CREATE TABLE Question
(
questiontext TEXT,
questionid INTEGER
constraint Question_pk
primary key
);
CREATE TABLE Survey
(
SurveyID INTEGER
constraint Survey_pk
primary key,
Description TEXT
);
CREATE TABLE IF NOT EXISTS "Answer"
(
AnswerText TEXT,
SurveyID INTEGER
constraint Answer_Survey_SurveyID_fk
references Survey,
UserID INTEGER,
QuestionID INTEGER
constraint Answer_Question_questionid_fk
references Question,
constraint Answer_pk
primary key (UserID, QuestionID)
);
|
movielens | Please list different IDs of movies that are the newest and have gotten the lowest rating. | Year contains relative value, higer year value refers to newer date; Year = 4 refers to newest date, Year = 1 refer to oldest date; Lowest rating = 1 | SELECT DISTINCT T1.movieid FROM u2base AS T1 INNER JOIN movies AS T2 ON T1.movieid = T2.movieid WHERE T2.year = 4 AND T1.rating = 1 | CREATE TABLE users
(
userid INTEGER default 0 not null
primary key,
age TEXT not null,
u_gender TEXT not null,
occupation TEXT not null
);
CREATE TABLE IF NOT EXISTS "directors"
(
directorid INTEGER not null
primary key,
d_quality INTEGER not null,
avg_revenue INTEGER not null
);
CREATE INDEX avg_revenue
on directors (avg_revenue);
CREATE INDEX d_quality
on directors (d_quality);
CREATE TABLE IF NOT EXISTS "actors"
(
actorid INTEGER not null
primary key,
a_gender TEXT not null,
a_quality INTEGER not null
);
CREATE TABLE IF NOT EXISTS "movies"
(
movieid INTEGER default 0 not null
primary key,
year INTEGER not null,
isEnglish TEXT not null,
country TEXT not null,
runningtime INTEGER not null
);
CREATE TABLE IF NOT EXISTS "movies2actors"
(
movieid INTEGER not null
references movies
on update cascade on delete cascade,
actorid INTEGER not null
references actors
on update cascade on delete cascade,
cast_num INTEGER not null,
primary key (movieid, actorid)
);
CREATE TABLE IF NOT EXISTS "movies2directors"
(
movieid INTEGER not null
references movies
on update cascade on delete cascade,
directorid INTEGER not null
references directors
on update cascade on delete cascade,
genre TEXT not null,
primary key (movieid, directorid)
);
CREATE TABLE IF NOT EXISTS "u2base"
(
userid INTEGER default 0 not null
references users
on update cascade on delete cascade,
movieid INTEGER not null
references movies
on update cascade on delete cascade,
rating TEXT not null,
primary key (userid, movieid)
);
|
mondial_geo | Please list the names of the countries with an inflation rate that's 30% above the average. | Average inflation rate = [sum(inflation) / count(countries)]; 30% above average implies inflation > 1.3 average inflation rate | SELECT T1.Name FROM country AS T1 INNER JOIN economy AS T2 ON T1.Code = T2.Country GROUP BY T1.Name, T2.Inflation HAVING T2.Inflation > AVG(T2.Inflation) * 1.3 | CREATE TABLE IF NOT EXISTS "borders"
(
Country1 TEXT default '' not null
constraint borders_ibfk_1
references country,
Country2 TEXT default '' not null
constraint borders_ibfk_2
references country,
Length REAL,
primary key (Country1, Country2)
);
CREATE TABLE IF NOT EXISTS "city"
(
Name TEXT default '' not null,
Country TEXT default '' not null
constraint city_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
Population INTEGER,
Longitude REAL,
Latitude REAL,
primary key (Name, Province),
constraint city_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "continent"
(
Name TEXT default '' not null
primary key,
Area REAL
);
CREATE TABLE IF NOT EXISTS "country"
(
Name TEXT not null
constraint ix_county_Name
unique,
Code TEXT default '' not null
primary key,
Capital TEXT,
Province TEXT,
Area REAL,
Population INTEGER
);
CREATE TABLE IF NOT EXISTS "desert"
(
Name TEXT default '' not null
primary key,
Area REAL,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "economy"
(
Country TEXT default '' not null
primary key
constraint economy_ibfk_1
references country
on update cascade on delete cascade,
GDP REAL,
Agriculture REAL,
Service REAL,
Industry REAL,
Inflation REAL
);
CREATE TABLE IF NOT EXISTS "encompasses"
(
Country TEXT not null
constraint encompasses_ibfk_1
references country
on update cascade on delete cascade,
Continent TEXT not null
constraint encompasses_ibfk_2
references continent
on update cascade on delete cascade,
Percentage REAL,
primary key (Country, Continent)
);
CREATE TABLE IF NOT EXISTS "ethnicGroup"
(
Country TEXT default '' not null
constraint ethnicGroup_ibfk_1
references country
on update cascade on delete cascade,
Name TEXT default '' not null,
Percentage REAL,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "geo_desert"
(
Desert TEXT default '' not null
constraint geo_desert_ibfk_3
references desert
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_desert_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Desert),
constraint geo_desert_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_estuary"
(
River TEXT default '' not null
constraint geo_estuary_ibfk_3
references river
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_estuary_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, River),
constraint geo_estuary_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_island"
(
Island TEXT default '' not null
constraint geo_island_ibfk_3
references island
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_island_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Island),
constraint geo_island_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_lake"
(
Lake TEXT default '' not null
constraint geo_lake_ibfk_3
references lake
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_lake_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Lake),
constraint geo_lake_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_mountain"
(
Mountain TEXT default '' not null
constraint geo_mountain_ibfk_3
references mountain
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_mountain_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Mountain),
constraint geo_mountain_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_river"
(
River TEXT default '' not null
constraint geo_river_ibfk_3
references river
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_river_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, River),
constraint geo_river_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_sea"
(
Sea TEXT default '' not null
constraint geo_sea_ibfk_3
references sea
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_sea_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Sea),
constraint geo_sea_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_source"
(
River TEXT default '' not null
constraint geo_source_ibfk_3
references river
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_source_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, River),
constraint geo_source_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "island"
(
Name TEXT default '' not null
primary key,
Islands TEXT,
Area REAL,
Height REAL,
Type TEXT,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "islandIn"
(
Island TEXT
constraint islandIn_ibfk_4
references island
on update cascade on delete cascade,
Sea TEXT
constraint islandIn_ibfk_3
references sea
on update cascade on delete cascade,
Lake TEXT
constraint islandIn_ibfk_1
references lake
on update cascade on delete cascade,
River TEXT
constraint islandIn_ibfk_2
references river
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "isMember"
(
Country TEXT default '' not null
constraint isMember_ibfk_1
references country
on update cascade on delete cascade,
Organization TEXT default '' not null
constraint isMember_ibfk_2
references organization
on update cascade on delete cascade,
Type TEXT default 'member',
primary key (Country, Organization)
);
CREATE TABLE IF NOT EXISTS "lake"
(
Name TEXT default '' not null
primary key,
Area REAL,
Depth REAL,
Altitude REAL,
Type TEXT,
River TEXT,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "language"
(
Country TEXT default '' not null
constraint language_ibfk_1
references country
on update cascade on delete cascade,
Name TEXT default '' not null,
Percentage REAL,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "located"
(
City TEXT,
Province TEXT,
Country TEXT
constraint located_ibfk_1
references country
on update cascade on delete cascade,
River TEXT
constraint located_ibfk_3
references river
on update cascade on delete cascade,
Lake TEXT
constraint located_ibfk_4
references lake
on update cascade on delete cascade,
Sea TEXT
constraint located_ibfk_5
references sea
on update cascade on delete cascade,
constraint located_ibfk_2
foreign key (City, Province) references city
on update cascade on delete cascade,
constraint located_ibfk_6
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "locatedOn"
(
City TEXT default '' not null,
Province TEXT default '' not null,
Country TEXT default '' not null
constraint locatedOn_ibfk_1
references country
on update cascade on delete cascade,
Island TEXT default '' not null
constraint locatedOn_ibfk_2
references island
on update cascade on delete cascade,
primary key (City, Province, Country, Island),
constraint locatedOn_ibfk_3
foreign key (City, Province) references city
on update cascade on delete cascade,
constraint locatedOn_ibfk_4
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "mergesWith"
(
Sea1 TEXT default '' not null
constraint mergesWith_ibfk_1
references sea
on update cascade on delete cascade,
Sea2 TEXT default '' not null
constraint mergesWith_ibfk_2
references sea
on update cascade on delete cascade,
primary key (Sea1, Sea2)
);
CREATE TABLE IF NOT EXISTS "mountain"
(
Name TEXT default '' not null
primary key,
Mountains TEXT,
Height REAL,
Type TEXT,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "mountainOnIsland"
(
Mountain TEXT default '' not null
constraint mountainOnIsland_ibfk_2
references mountain
on update cascade on delete cascade,
Island TEXT default '' not null
constraint mountainOnIsland_ibfk_1
references island
on update cascade on delete cascade,
primary key (Mountain, Island)
);
CREATE TABLE IF NOT EXISTS "organization"
(
Abbreviation TEXT not null
primary key,
Name TEXT not null
constraint ix_organization_OrgNameUnique
unique,
City TEXT,
Country TEXT
constraint organization_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT,
Established DATE,
constraint organization_ibfk_2
foreign key (City, Province) references city
on update cascade on delete cascade,
constraint organization_ibfk_3
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "politics"
(
Country TEXT default '' not null
primary key
constraint politics_ibfk_1
references country
on update cascade on delete cascade,
Independence DATE,
Dependent TEXT
constraint politics_ibfk_2
references country
on update cascade on delete cascade,
Government TEXT
);
CREATE TABLE IF NOT EXISTS "population"
(
Country TEXT default '' not null
primary key
constraint population_ibfk_1
references country
on update cascade on delete cascade,
Population_Growth REAL,
Infant_Mortality REAL
);
CREATE TABLE IF NOT EXISTS "province"
(
Name TEXT not null,
Country TEXT not null
constraint province_ibfk_1
references country
on update cascade on delete cascade,
Population INTEGER,
Area REAL,
Capital TEXT,
CapProv TEXT,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "religion"
(
Country TEXT default '' not null
constraint religion_ibfk_1
references country
on update cascade on delete cascade,
Name TEXT default '' not null,
Percentage REAL,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "river"
(
Name TEXT default '' not null
primary key,
River TEXT,
Lake TEXT
constraint river_ibfk_1
references lake
on update cascade on delete cascade,
Sea TEXT,
Length REAL,
SourceLongitude REAL,
SourceLatitude REAL,
Mountains TEXT,
SourceAltitude REAL,
EstuaryLongitude REAL,
EstuaryLatitude REAL
);
CREATE TABLE IF NOT EXISTS "sea"
(
Name TEXT default '' not null
primary key,
Depth REAL
);
CREATE TABLE IF NOT EXISTS "target"
(
Country TEXT not null
primary key
constraint target_Country_fkey
references country
on update cascade on delete cascade,
Target TEXT
);
|
authors | What is the name of the co-authors of the paper titled 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker'? | paper titled 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker' refers to Title = 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker' | SELECT T1.Name FROM PaperAuthor AS T1 INNER JOIN Paper AS T2 ON T1.PaperId = T2.Id WHERE T2.Title = 'Particle identification using the time-over-threshold method in the ATLAS Transition Radiation Tracker' | CREATE TABLE IF NOT EXISTS "Author"
(
Id INTEGER
constraint Author_pk
primary key,
Name TEXT,
Affiliation TEXT
);
CREATE TABLE IF NOT EXISTS "Conference"
(
Id INTEGER
constraint Conference_pk
primary key,
ShortName TEXT,
FullName TEXT,
HomePage TEXT
);
CREATE TABLE IF NOT EXISTS "Journal"
(
Id INTEGER
constraint Journal_pk
primary key,
ShortName TEXT,
FullName TEXT,
HomePage TEXT
);
CREATE TABLE Paper
(
Id INTEGER
primary key,
Title TEXT,
Year INTEGER,
ConferenceId INTEGER,
JournalId INTEGER,
Keyword TEXT,
foreign key (ConferenceId) references Conference(Id),
foreign key (JournalId) references Journal(Id)
);
CREATE TABLE PaperAuthor
(
PaperId INTEGER,
AuthorId INTEGER,
Name TEXT,
Affiliation TEXT,
foreign key (PaperId) references Paper(Id),
foreign key (AuthorId) references Author(Id)
);
|
airline | Give the name of the airline to which tail number N202NN belongs to. | name of the airline refers to Description; tail number refers to TAIL_NUM; TAIL_NUM = 'N202NN'; | SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.TAIL_NUM = 'N202NN' GROUP BY T2.Description | CREATE TABLE IF NOT EXISTS "Air Carriers"
(
Code INTEGER
primary key,
Description TEXT
);
CREATE TABLE Airports
(
Code TEXT
primary key,
Description TEXT
);
CREATE TABLE Airlines
(
FL_DATE TEXT,
OP_CARRIER_AIRLINE_ID INTEGER,
TAIL_NUM TEXT,
OP_CARRIER_FL_NUM INTEGER,
ORIGIN_AIRPORT_ID INTEGER,
ORIGIN_AIRPORT_SEQ_ID INTEGER,
ORIGIN_CITY_MARKET_ID INTEGER,
ORIGIN TEXT,
DEST_AIRPORT_ID INTEGER,
DEST_AIRPORT_SEQ_ID INTEGER,
DEST_CITY_MARKET_ID INTEGER,
DEST TEXT,
CRS_DEP_TIME INTEGER,
DEP_TIME INTEGER,
DEP_DELAY INTEGER,
DEP_DELAY_NEW INTEGER,
ARR_TIME INTEGER,
ARR_DELAY INTEGER,
ARR_DELAY_NEW INTEGER,
CANCELLED INTEGER,
CANCELLATION_CODE TEXT,
CRS_ELAPSED_TIME INTEGER,
ACTUAL_ELAPSED_TIME INTEGER,
CARRIER_DELAY INTEGER,
WEATHER_DELAY INTEGER,
NAS_DELAY INTEGER,
SECURITY_DELAY INTEGER,
LATE_AIRCRAFT_DELAY INTEGER,
FOREIGN KEY (ORIGIN) REFERENCES Airports(Code),
FOREIGN KEY (DEST) REFERENCES Airports(Code),
FOREIGN KEY (OP_CARRIER_AIRLINE_ID) REFERENCES "Air Carriers"(Code)
);
|
hockey | How much is the total goals for player with player ID aaltoan01 and how old is this person? | total goals refer to SUM(G); how old = SUBTRACT(YEAR(CURDATE, birthYear); | SELECT SUM(T2.G), STRFTIME('%Y', CURRENT_TIMESTAMP) - T1.birthyear FROM Master AS T1 INNER JOIN Scoring AS T2 ON T1.playerID = T2.playerID WHERE T1.playerID = 'aaltoan01' GROUP BY T1.birthyear | CREATE TABLE AwardsMisc
(
name TEXT not null
primary key,
ID TEXT,
award TEXT,
year INTEGER,
lgID TEXT,
note TEXT
);
CREATE TABLE HOF
(
year INTEGER,
hofID TEXT not null
primary key,
name TEXT,
category TEXT
);
CREATE TABLE Teams
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
franchID TEXT,
confID TEXT,
divID TEXT,
rank INTEGER,
playoff TEXT,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
OTL TEXT,
Pts INTEGER,
SoW TEXT,
SoL TEXT,
GF INTEGER,
GA INTEGER,
name TEXT,
PIM TEXT,
BenchMinor TEXT,
PPG TEXT,
PPC TEXT,
SHA TEXT,
PKG TEXT,
PKC TEXT,
SHF TEXT,
primary key (year, tmID)
);
CREATE TABLE Coaches
(
coachID TEXT not null,
year INTEGER not null,
tmID TEXT not null,
lgID TEXT,
stint INTEGER not null,
notes TEXT,
g INTEGER,
w INTEGER,
l INTEGER,
t INTEGER,
postg TEXT,
postw TEXT,
postl TEXT,
postt TEXT,
primary key (coachID, year, tmID, stint),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE AwardsCoaches
(
coachID TEXT,
award TEXT,
year INTEGER,
lgID TEXT,
note TEXT,
foreign key (coachID) references Coaches (coachID)
);
CREATE TABLE Master
(
playerID TEXT,
coachID TEXT,
hofID TEXT,
firstName TEXT,
lastName TEXT not null,
nameNote TEXT,
nameGiven TEXT,
nameNick TEXT,
height TEXT,
weight TEXT,
shootCatch TEXT,
legendsID TEXT,
ihdbID TEXT,
hrefID TEXT,
firstNHL TEXT,
lastNHL TEXT,
firstWHA TEXT,
lastWHA TEXT,
pos TEXT,
birthYear TEXT,
birthMon TEXT,
birthDay TEXT,
birthCountry TEXT,
birthState TEXT,
birthCity TEXT,
deathYear TEXT,
deathMon TEXT,
deathDay TEXT,
deathCountry TEXT,
deathState TEXT,
deathCity TEXT,
foreign key (coachID) references Coaches (coachID)
on update cascade on delete cascade
);
CREATE TABLE AwardsPlayers
(
playerID TEXT not null,
award TEXT not null,
year INTEGER not null,
lgID TEXT,
note TEXT,
pos TEXT,
primary key (playerID, award, year),
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE CombinedShutouts
(
year INTEGER,
month INTEGER,
date INTEGER,
tmID TEXT,
oppID TEXT,
"R/P" TEXT,
IDgoalie1 TEXT,
IDgoalie2 TEXT,
foreign key (IDgoalie1) references Master (playerID)
on update cascade on delete cascade,
foreign key (IDgoalie2) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE Goalies
(
playerID TEXT not null,
year INTEGER not null,
stint INTEGER not null,
tmID TEXT,
lgID TEXT,
GP TEXT,
Min TEXT,
W TEXT,
L TEXT,
"T/OL" TEXT,
ENG TEXT,
SHO TEXT,
GA TEXT,
SA TEXT,
PostGP TEXT,
PostMin TEXT,
PostW TEXT,
PostL TEXT,
PostT TEXT,
PostENG TEXT,
PostSHO TEXT,
PostGA TEXT,
PostSA TEXT,
primary key (playerID, year, stint),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE GoaliesSC
(
playerID TEXT not null,
year INTEGER not null,
tmID TEXT,
lgID TEXT,
GP INTEGER,
Min INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
SHO INTEGER,
GA INTEGER,
primary key (playerID, year),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE GoaliesShootout
(
playerID TEXT,
year INTEGER,
stint INTEGER,
tmID TEXT,
W INTEGER,
L INTEGER,
SA INTEGER,
GA INTEGER,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE Scoring
(
playerID TEXT,
year INTEGER,
stint INTEGER,
tmID TEXT,
lgID TEXT,
pos TEXT,
GP INTEGER,
G INTEGER,
A INTEGER,
Pts INTEGER,
PIM INTEGER,
"+/-" TEXT,
PPG TEXT,
PPA TEXT,
SHG TEXT,
SHA TEXT,
GWG TEXT,
GTG TEXT,
SOG TEXT,
PostGP TEXT,
PostG TEXT,
PostA TEXT,
PostPts TEXT,
PostPIM TEXT,
"Post+/-" TEXT,
PostPPG TEXT,
PostPPA TEXT,
PostSHG TEXT,
PostSHA TEXT,
PostGWG TEXT,
PostSOG TEXT,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE ScoringSC
(
playerID TEXT,
year INTEGER,
tmID TEXT,
lgID TEXT,
pos TEXT,
GP INTEGER,
G INTEGER,
A INTEGER,
Pts INTEGER,
PIM INTEGER,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE ScoringShootout
(
playerID TEXT,
year INTEGER,
stint INTEGER,
tmID TEXT,
S INTEGER,
G INTEGER,
GDG INTEGER,
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE ScoringSup
(
playerID TEXT,
year INTEGER,
PPA TEXT,
SHA TEXT,
foreign key (playerID) references Master (playerID)
on update cascade on delete cascade
);
CREATE TABLE SeriesPost
(
year INTEGER,
round TEXT,
series TEXT,
tmIDWinner TEXT,
lgIDWinner TEXT,
tmIDLoser TEXT,
lgIDLoser TEXT,
W INTEGER,
L INTEGER,
T INTEGER,
GoalsWinner INTEGER,
GoalsLoser INTEGER,
note TEXT,
foreign key (year, tmIDWinner) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (year, tmIDLoser) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE TeamSplits
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
hW INTEGER,
hL INTEGER,
hT INTEGER,
hOTL TEXT,
rW INTEGER,
rL INTEGER,
rT INTEGER,
rOTL TEXT,
SepW TEXT,
SepL TEXT,
SepT TEXT,
SepOL TEXT,
OctW TEXT,
OctL TEXT,
OctT TEXT,
OctOL TEXT,
NovW TEXT,
NovL TEXT,
NovT TEXT,
NovOL TEXT,
DecW TEXT,
DecL TEXT,
DecT TEXT,
DecOL TEXT,
JanW INTEGER,
JanL INTEGER,
JanT INTEGER,
JanOL TEXT,
FebW INTEGER,
FebL INTEGER,
FebT INTEGER,
FebOL TEXT,
MarW TEXT,
MarL TEXT,
MarT TEXT,
MarOL TEXT,
AprW TEXT,
AprL TEXT,
AprT TEXT,
AprOL TEXT,
primary key (year, tmID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE TeamVsTeam
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
oppID TEXT not null,
W INTEGER,
L INTEGER,
T INTEGER,
OTL TEXT,
primary key (year, tmID, oppID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade,
foreign key (oppID, year) references Teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE TeamsHalf
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
half INTEGER not null,
rank INTEGER,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
GF INTEGER,
GA INTEGER,
primary key (year, tmID, half),
foreign key (tmID, year) references Teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE TeamsPost
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
GF INTEGER,
GA INTEGER,
PIM TEXT,
BenchMinor TEXT,
PPG TEXT,
PPC TEXT,
SHA TEXT,
PKG TEXT,
PKC TEXT,
SHF TEXT,
primary key (year, tmID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE TeamsSC
(
year INTEGER not null,
lgID TEXT,
tmID TEXT not null,
G INTEGER,
W INTEGER,
L INTEGER,
T INTEGER,
GF INTEGER,
GA INTEGER,
PIM TEXT,
primary key (year, tmID),
foreign key (year, tmID) references Teams (year, tmID)
on update cascade on delete cascade
);
CREATE TABLE abbrev
(
Type TEXT not null,
Code TEXT not null,
Fullname TEXT,
primary key (Type, Code)
);
|
olympics | Calculate the percentage of women who have participated in Equestrianism Mixed Three-Day Event, Individual. | DIVIDE(COUNT(person_id where gender = 'F), COUNT(person_id)) as percentage where event_name = 'Equestrianism Mixed Three-Day Event, Individual'; | SELECT CAST(COUNT(CASE WHEN T1.gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN event AS T4 ON T3.event_id = T4.id WHERE T4.event_name = 'Equestrianism Mixed Three-Day Event, Individual' | CREATE TABLE city
(
id INTEGER not null
primary key,
city_name TEXT default NULL
);
CREATE TABLE games
(
id INTEGER not null
primary key,
games_year INTEGER default NULL,
games_name TEXT default NULL,
season TEXT default NULL
);
CREATE TABLE games_city
(
games_id INTEGER default NULL,
city_id INTEGER default NULL,
foreign key (city_id) references city(id),
foreign key (games_id) references games(id)
);
CREATE TABLE medal
(
id INTEGER not null
primary key,
medal_name TEXT default NULL
);
CREATE TABLE noc_region
(
id INTEGER not null
primary key,
noc TEXT default NULL,
region_name TEXT default NULL
);
CREATE TABLE person
(
id INTEGER not null
primary key,
full_name TEXT default NULL,
gender TEXT default NULL,
height INTEGER default NULL,
weight INTEGER default NULL
);
CREATE TABLE games_competitor
(
id INTEGER not null
primary key,
games_id INTEGER default NULL,
person_id INTEGER default NULL,
age INTEGER default NULL,
foreign key (games_id) references games(id),
foreign key (person_id) references person(id)
);
CREATE TABLE person_region
(
person_id INTEGER default NULL,
region_id INTEGER default NULL,
foreign key (person_id) references person(id),
foreign key (region_id) references noc_region(id)
);
CREATE TABLE sport
(
id INTEGER not null
primary key,
sport_name TEXT default NULL
);
CREATE TABLE event
(
id INTEGER not null
primary key,
sport_id INTEGER default NULL,
event_name TEXT default NULL,
foreign key (sport_id) references sport(id)
);
CREATE TABLE competitor_event
(
event_id INTEGER default NULL,
competitor_id INTEGER default NULL,
medal_id INTEGER default NULL,
foreign key (competitor_id) references games_competitor(id),
foreign key (event_id) references event(id),
foreign key (medal_id) references medal(id)
);
|
retail_world | Which customer have the biggest purchase in one order and where does this order being ship to? | biggest purchase refers to max(ProductID.Order_Details); ship to refers to ShipCountry | SELECT T1.CompanyName, T2.ShipCountry FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID GROUP BY T1.CompanyName, T2.ShipCountry ORDER BY COUNT(T3.ProductID) DESC LIMIT 1 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
PostalCode TEXT,
Country TEXT
);
CREATE TABLE Employees
(
EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT,
LastName TEXT,
FirstName TEXT,
BirthDate DATE,
Photo TEXT,
Notes TEXT
);
CREATE TABLE Shippers(
ShipperID INTEGER PRIMARY KEY AUTOINCREMENT,
ShipperName TEXT,
Phone TEXT
);
CREATE TABLE Suppliers(
SupplierID INTEGER PRIMARY KEY AUTOINCREMENT,
SupplierName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
PostalCode TEXT,
Country TEXT,
Phone TEXT
);
CREATE TABLE Products(
ProductID INTEGER PRIMARY KEY AUTOINCREMENT,
ProductName TEXT,
SupplierID INTEGER,
CategoryID INTEGER,
Unit TEXT,
Price REAL DEFAULT 0,
FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID),
FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID)
);
CREATE TABLE Orders(
OrderID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerID INTEGER,
EmployeeID INTEGER,
OrderDate DATETIME,
ShipperID INTEGER,
FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID),
FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),
FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID)
);
CREATE TABLE OrderDetails(
OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT,
OrderID INTEGER,
ProductID INTEGER,
Quantity INTEGER,
FOREIGN KEY (OrderID) REFERENCES Orders (OrderID),
FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
);
|
music_platform_2 | Which titles have the content "love" but the category is art produced between 2018 and 2019. | content love refers to content = 'love'; 'arts' is the category; produced between 2018 and 2019 refers to year (created_at) BETWEEN 2018 and 2019 | SELECT DISTINCT T2.title FROM categories AS T1 INNER JOIN reviews AS T2 ON T2.podcast_id = T1.podcast_id WHERE (T2.created_at LIKE '2018-%' AND T1.category = 'arts' AND T2.content LIKE '%love%') OR (T2.created_at LIKE '2019-%' AND T1.category = 'arts' AND T2.content LIKE '%love%') | CREATE TABLE runs (
run_at text not null,
max_rowid integer not null,
reviews_added integer not null
);
CREATE TABLE podcasts (
podcast_id text primary key,
itunes_id integer not null,
slug text not null,
itunes_url text not null,
title text not null
);
CREATE TABLE IF NOT EXISTS "reviews"
(
podcast_id TEXT not null
constraint reviews_podcasts_podcast_id_fk
references podcasts,
title TEXT not null,
content TEXT not null,
rating INTEGER not null,
author_id TEXT not null,
created_at TEXT not null
);
CREATE TABLE IF NOT EXISTS "categories"
(
podcast_id TEXT not null
constraint categories_podcasts_podcast_id_fk
references podcasts,
category TEXT not null,
constraint "PRIMARY"
primary key (podcast_id, category)
);
CREATE INDEX category_podcast_id_idx
on categories (podcast_id);
|
mondial_geo | What's the name of the second biggest desert? | SELECT Name FROM desert ORDER BY Area DESC LIMIT 1, 1 | CREATE TABLE IF NOT EXISTS "borders"
(
Country1 TEXT default '' not null
constraint borders_ibfk_1
references country,
Country2 TEXT default '' not null
constraint borders_ibfk_2
references country,
Length REAL,
primary key (Country1, Country2)
);
CREATE TABLE IF NOT EXISTS "city"
(
Name TEXT default '' not null,
Country TEXT default '' not null
constraint city_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
Population INTEGER,
Longitude REAL,
Latitude REAL,
primary key (Name, Province),
constraint city_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "continent"
(
Name TEXT default '' not null
primary key,
Area REAL
);
CREATE TABLE IF NOT EXISTS "country"
(
Name TEXT not null
constraint ix_county_Name
unique,
Code TEXT default '' not null
primary key,
Capital TEXT,
Province TEXT,
Area REAL,
Population INTEGER
);
CREATE TABLE IF NOT EXISTS "desert"
(
Name TEXT default '' not null
primary key,
Area REAL,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "economy"
(
Country TEXT default '' not null
primary key
constraint economy_ibfk_1
references country
on update cascade on delete cascade,
GDP REAL,
Agriculture REAL,
Service REAL,
Industry REAL,
Inflation REAL
);
CREATE TABLE IF NOT EXISTS "encompasses"
(
Country TEXT not null
constraint encompasses_ibfk_1
references country
on update cascade on delete cascade,
Continent TEXT not null
constraint encompasses_ibfk_2
references continent
on update cascade on delete cascade,
Percentage REAL,
primary key (Country, Continent)
);
CREATE TABLE IF NOT EXISTS "ethnicGroup"
(
Country TEXT default '' not null
constraint ethnicGroup_ibfk_1
references country
on update cascade on delete cascade,
Name TEXT default '' not null,
Percentage REAL,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "geo_desert"
(
Desert TEXT default '' not null
constraint geo_desert_ibfk_3
references desert
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_desert_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Desert),
constraint geo_desert_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_estuary"
(
River TEXT default '' not null
constraint geo_estuary_ibfk_3
references river
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_estuary_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, River),
constraint geo_estuary_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_island"
(
Island TEXT default '' not null
constraint geo_island_ibfk_3
references island
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_island_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Island),
constraint geo_island_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_lake"
(
Lake TEXT default '' not null
constraint geo_lake_ibfk_3
references lake
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_lake_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Lake),
constraint geo_lake_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_mountain"
(
Mountain TEXT default '' not null
constraint geo_mountain_ibfk_3
references mountain
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_mountain_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Mountain),
constraint geo_mountain_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_river"
(
River TEXT default '' not null
constraint geo_river_ibfk_3
references river
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_river_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, River),
constraint geo_river_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_sea"
(
Sea TEXT default '' not null
constraint geo_sea_ibfk_3
references sea
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_sea_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, Sea),
constraint geo_sea_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_source"
(
River TEXT default '' not null
constraint geo_source_ibfk_3
references river
on update cascade on delete cascade,
Country TEXT default '' not null
constraint geo_source_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT default '' not null,
primary key (Province, Country, River),
constraint geo_source_ibfk_2
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "island"
(
Name TEXT default '' not null
primary key,
Islands TEXT,
Area REAL,
Height REAL,
Type TEXT,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "islandIn"
(
Island TEXT
constraint islandIn_ibfk_4
references island
on update cascade on delete cascade,
Sea TEXT
constraint islandIn_ibfk_3
references sea
on update cascade on delete cascade,
Lake TEXT
constraint islandIn_ibfk_1
references lake
on update cascade on delete cascade,
River TEXT
constraint islandIn_ibfk_2
references river
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "isMember"
(
Country TEXT default '' not null
constraint isMember_ibfk_1
references country
on update cascade on delete cascade,
Organization TEXT default '' not null
constraint isMember_ibfk_2
references organization
on update cascade on delete cascade,
Type TEXT default 'member',
primary key (Country, Organization)
);
CREATE TABLE IF NOT EXISTS "lake"
(
Name TEXT default '' not null
primary key,
Area REAL,
Depth REAL,
Altitude REAL,
Type TEXT,
River TEXT,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "language"
(
Country TEXT default '' not null
constraint language_ibfk_1
references country
on update cascade on delete cascade,
Name TEXT default '' not null,
Percentage REAL,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "located"
(
City TEXT,
Province TEXT,
Country TEXT
constraint located_ibfk_1
references country
on update cascade on delete cascade,
River TEXT
constraint located_ibfk_3
references river
on update cascade on delete cascade,
Lake TEXT
constraint located_ibfk_4
references lake
on update cascade on delete cascade,
Sea TEXT
constraint located_ibfk_5
references sea
on update cascade on delete cascade,
constraint located_ibfk_2
foreign key (City, Province) references city
on update cascade on delete cascade,
constraint located_ibfk_6
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "locatedOn"
(
City TEXT default '' not null,
Province TEXT default '' not null,
Country TEXT default '' not null
constraint locatedOn_ibfk_1
references country
on update cascade on delete cascade,
Island TEXT default '' not null
constraint locatedOn_ibfk_2
references island
on update cascade on delete cascade,
primary key (City, Province, Country, Island),
constraint locatedOn_ibfk_3
foreign key (City, Province) references city
on update cascade on delete cascade,
constraint locatedOn_ibfk_4
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "mergesWith"
(
Sea1 TEXT default '' not null
constraint mergesWith_ibfk_1
references sea
on update cascade on delete cascade,
Sea2 TEXT default '' not null
constraint mergesWith_ibfk_2
references sea
on update cascade on delete cascade,
primary key (Sea1, Sea2)
);
CREATE TABLE IF NOT EXISTS "mountain"
(
Name TEXT default '' not null
primary key,
Mountains TEXT,
Height REAL,
Type TEXT,
Longitude REAL,
Latitude REAL
);
CREATE TABLE IF NOT EXISTS "mountainOnIsland"
(
Mountain TEXT default '' not null
constraint mountainOnIsland_ibfk_2
references mountain
on update cascade on delete cascade,
Island TEXT default '' not null
constraint mountainOnIsland_ibfk_1
references island
on update cascade on delete cascade,
primary key (Mountain, Island)
);
CREATE TABLE IF NOT EXISTS "organization"
(
Abbreviation TEXT not null
primary key,
Name TEXT not null
constraint ix_organization_OrgNameUnique
unique,
City TEXT,
Country TEXT
constraint organization_ibfk_1
references country
on update cascade on delete cascade,
Province TEXT,
Established DATE,
constraint organization_ibfk_2
foreign key (City, Province) references city
on update cascade on delete cascade,
constraint organization_ibfk_3
foreign key (Province, Country) references province
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "politics"
(
Country TEXT default '' not null
primary key
constraint politics_ibfk_1
references country
on update cascade on delete cascade,
Independence DATE,
Dependent TEXT
constraint politics_ibfk_2
references country
on update cascade on delete cascade,
Government TEXT
);
CREATE TABLE IF NOT EXISTS "population"
(
Country TEXT default '' not null
primary key
constraint population_ibfk_1
references country
on update cascade on delete cascade,
Population_Growth REAL,
Infant_Mortality REAL
);
CREATE TABLE IF NOT EXISTS "province"
(
Name TEXT not null,
Country TEXT not null
constraint province_ibfk_1
references country
on update cascade on delete cascade,
Population INTEGER,
Area REAL,
Capital TEXT,
CapProv TEXT,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "religion"
(
Country TEXT default '' not null
constraint religion_ibfk_1
references country
on update cascade on delete cascade,
Name TEXT default '' not null,
Percentage REAL,
primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "river"
(
Name TEXT default '' not null
primary key,
River TEXT,
Lake TEXT
constraint river_ibfk_1
references lake
on update cascade on delete cascade,
Sea TEXT,
Length REAL,
SourceLongitude REAL,
SourceLatitude REAL,
Mountains TEXT,
SourceAltitude REAL,
EstuaryLongitude REAL,
EstuaryLatitude REAL
);
CREATE TABLE IF NOT EXISTS "sea"
(
Name TEXT default '' not null
primary key,
Depth REAL
);
CREATE TABLE IF NOT EXISTS "target"
(
Country TEXT not null
primary key
constraint target_Country_fkey
references country
on update cascade on delete cascade,
Target TEXT
);
|
|
simpson_episodes | Among episodes aired in 2009, which episode has received the worst response based on the rating. | aired in 2009 refers to year(air_date) = 2009; received the worst response based on the rating refers to MIN(rating) | SELECT episode_id FROM Episode WHERE air_date LIKE '2009%' ORDER BY rating LIMIT 1; | CREATE TABLE IF NOT EXISTS "Episode"
(
episode_id TEXT
constraint Episode_pk
primary key,
season INTEGER,
episode INTEGER,
number_in_series INTEGER,
title TEXT,
summary TEXT,
air_date TEXT,
episode_image TEXT,
rating REAL,
votes INTEGER
);
CREATE TABLE Person
(
name TEXT
constraint Person_pk
primary key,
birthdate TEXT,
birth_name TEXT,
birth_place TEXT,
birth_region TEXT,
birth_country TEXT,
height_meters REAL,
nickname TEXT
);
CREATE TABLE Award
(
award_id INTEGER
primary key,
organization TEXT,
year INTEGER,
award_category TEXT,
award TEXT,
person TEXT,
role TEXT,
episode_id TEXT,
season TEXT,
song TEXT,
result TEXT,
foreign key (person) references Person(name),
foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Character_Award
(
award_id INTEGER,
character TEXT,
foreign key (award_id) references Award(award_id)
);
CREATE TABLE Credit
(
episode_id TEXT,
category TEXT,
person TEXT,
role TEXT,
credited TEXT,
foreign key (episode_id) references Episode(episode_id),
foreign key (person) references Person(name)
);
CREATE TABLE Keyword
(
episode_id TEXT,
keyword TEXT,
primary key (episode_id, keyword),
foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Vote
(
episode_id TEXT,
stars INTEGER,
votes INTEGER,
percent REAL,
foreign key (episode_id) references Episode(episode_id)
);
|
codebase_comments | What is the task of method number 2? | task of the method refers to the second part of the Name after the "."; method number refers to Method_100k.Id; Method_100k.Id = 2; | SELECT SUBSTR(SUBSTR(Name, INSTR(Name, '.') + 1), 1, INSTR(SUBSTR(Name, INSTR(Name, '.') + 1), '.') - 1) task FROM Method WHERE Id = 2 | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "Method"
(
Id INTEGER not null
primary key autoincrement,
Name TEXT,
FullComment TEXT,
Summary TEXT,
ApiCalls TEXT,
CommentIsXml INTEGER,
SampledAt INTEGER,
SolutionId INTEGER,
Lang TEXT,
NameTokenized TEXT
);
CREATE TABLE IF NOT EXISTS "MethodParameter"
(
Id INTEGER not null
primary key autoincrement,
MethodId TEXT,
Type TEXT,
Name TEXT
);
CREATE TABLE Repo
(
Id INTEGER not null
primary key autoincrement,
Url TEXT,
Stars INTEGER,
Forks INTEGER,
Watchers INTEGER,
ProcessedTime INTEGER
);
CREATE TABLE Solution
(
Id INTEGER not null
primary key autoincrement,
RepoId INTEGER,
Path TEXT,
ProcessedTime INTEGER,
WasCompiled INTEGER
);
|
retails | What is the biggest discount among all orders for the part "burnished seashell gainsboro navajo chocolate"? | the biggest discount refers to max(l_discount); part "burnished seashell gainsboro navajo chocolate" refers to p_name = 'burnished seashell gainsboro navajo chocolate' | SELECT MAX(T1.l_discount) FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name = 'burnished seashell gainsboro navajo chocolate' | CREATE TABLE `customer` (
`c_custkey` INTEGER NOT NULL,
`c_mktsegment` TEXT DEFAULT NULL,
`c_nationkey` INTEGER DEFAULT NULL,
`c_name` TEXT DEFAULT NULL,
`c_address` TEXT DEFAULT NULL,
`c_phone` TEXT DEFAULT NULL,
`c_acctbal` REAL DEFAULT NULL,
`c_comment` TEXT DEFAULT NULL,
PRIMARY KEY (`c_custkey`),
FOREIGN KEY (`c_nationkey`) REFERENCES `nation` (`n_nationkey`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE lineitem
(
l_shipdate DATE null,
l_orderkey INTEGER not null,
l_discount REAL not null,
l_extendedprice REAL not null,
l_suppkey INTEGER not null,
l_quantity INTEGER not null,
l_returnflag TEXT null,
l_partkey INTEGER not null,
l_linestatus TEXT null,
l_tax REAL not null,
l_commitdate DATE null,
l_receiptdate DATE null,
l_shipmode TEXT null,
l_linenumber INTEGER not null,
l_shipinstruct TEXT null,
l_comment TEXT null,
primary key (l_orderkey, l_linenumber),
foreign key (l_orderkey) references orders (o_orderkey)
on update cascade on delete cascade,
foreign key (l_partkey, l_suppkey) references partsupp (ps_partkey, ps_suppkey)
on update cascade on delete cascade
);
CREATE TABLE nation
(
n_nationkey INTEGER not null
primary key,
n_name TEXT null,
n_regionkey INTEGER null,
n_comment TEXT null,
foreign key (n_regionkey) references region (r_regionkey)
on update cascade on delete cascade
);
CREATE TABLE orders
(
o_orderdate DATE null,
o_orderkey INTEGER not null
primary key,
o_custkey INTEGER not null,
o_orderpriority TEXT null,
o_shippriority INTEGER null,
o_clerk TEXT null,
o_orderstatus TEXT null,
o_totalprice REAL null,
o_comment TEXT null,
foreign key (o_custkey) references customer (c_custkey)
on update cascade on delete cascade
);
CREATE TABLE part
(
p_partkey INTEGER not null
primary key,
p_type TEXT null,
p_size INTEGER null,
p_brand TEXT null,
p_name TEXT null,
p_container TEXT null,
p_mfgr TEXT null,
p_retailprice REAL null,
p_comment TEXT null
);
CREATE TABLE partsupp
(
ps_partkey INTEGER not null,
ps_suppkey INTEGER not null,
ps_supplycost REAL not null,
ps_availqty INTEGER null,
ps_comment TEXT null,
primary key (ps_partkey, ps_suppkey),
foreign key (ps_partkey) references part (p_partkey)
on update cascade on delete cascade,
foreign key (ps_suppkey) references supplier (s_suppkey)
on update cascade on delete cascade
);
CREATE TABLE region
(
r_regionkey INTEGER not null
primary key,
r_name TEXT null,
r_comment TEXT null
);
CREATE TABLE supplier
(
s_suppkey INTEGER not null
primary key,
s_nationkey INTEGER null,
s_comment TEXT null,
s_name TEXT null,
s_address TEXT null,
s_phone TEXT null,
s_acctbal REAL null,
foreign key (s_nationkey) references nation (n_nationkey)
);
|
retail_world | Please list all the territories in the Eastern Region. | territories refers to TerritoryDescription; Eastern Region refers to RegionDescription = 'Eastern'; | SELECT DISTINCT T1.TerritoryDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
CategoryName TEXT,
Description TEXT
);
CREATE TABLE Customers
(
CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
PostalCode TEXT,
Country TEXT
);
CREATE TABLE Employees
(
EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT,
LastName TEXT,
FirstName TEXT,
BirthDate DATE,
Photo TEXT,
Notes TEXT
);
CREATE TABLE Shippers(
ShipperID INTEGER PRIMARY KEY AUTOINCREMENT,
ShipperName TEXT,
Phone TEXT
);
CREATE TABLE Suppliers(
SupplierID INTEGER PRIMARY KEY AUTOINCREMENT,
SupplierName TEXT,
ContactName TEXT,
Address TEXT,
City TEXT,
PostalCode TEXT,
Country TEXT,
Phone TEXT
);
CREATE TABLE Products(
ProductID INTEGER PRIMARY KEY AUTOINCREMENT,
ProductName TEXT,
SupplierID INTEGER,
CategoryID INTEGER,
Unit TEXT,
Price REAL DEFAULT 0,
FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID),
FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID)
);
CREATE TABLE Orders(
OrderID INTEGER PRIMARY KEY AUTOINCREMENT,
CustomerID INTEGER,
EmployeeID INTEGER,
OrderDate DATETIME,
ShipperID INTEGER,
FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID),
FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),
FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID)
);
CREATE TABLE OrderDetails(
OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT,
OrderID INTEGER,
ProductID INTEGER,
Quantity INTEGER,
FOREIGN KEY (OrderID) REFERENCES Orders (OrderID),
FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
);
|