db_id
stringlengths 4
28
| question
stringlengths 24
325
| evidence
stringlengths 0
673
| SQL
stringlengths 23
804
| schema
stringlengths 352
37.3k
|
---|---|---|---|---|
sales | List down product names of free gifts. | free gifts refers to Price = 0; | SELECT Name FROM Products WHERE Price = 0 | 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
);
|
address | Name the country with the largest number of households in a residential area. | the largest number of households refers to MAX(households); | SELECT T1.county FROM country AS T1 INNER JOIN zip_data AS T2 ON T1.zip_code = T2.zip_code GROUP BY T1.county ORDER BY T2.households DESC LIMIT 1 | CREATE TABLE CBSA
(
CBSA INTEGER
primary key,
CBSA_name TEXT,
CBSA_type TEXT
);
CREATE TABLE state
(
abbreviation TEXT
primary key,
name TEXT
);
CREATE TABLE congress
(
cognress_rep_id TEXT
primary key,
first_name TEXT,
last_name TEXT,
CID TEXT,
party TEXT,
state TEXT,
abbreviation TEXT,
House TEXT,
District INTEGER,
land_area REAL,
foreign key (abbreviation) references state(abbreviation)
);
CREATE TABLE zip_data
(
zip_code INTEGER
primary key,
city TEXT,
state TEXT,
multi_county TEXT,
type TEXT,
organization TEXT,
time_zone TEXT,
daylight_savings TEXT,
latitude REAL,
longitude REAL,
elevation INTEGER,
state_fips INTEGER,
county_fips INTEGER,
region TEXT,
division TEXT,
population_2020 INTEGER,
population_2010 INTEGER,
households INTEGER,
avg_house_value INTEGER,
avg_income_per_household INTEGER,
persons_per_household REAL,
white_population INTEGER,
black_population INTEGER,
hispanic_population INTEGER,
asian_population INTEGER,
american_indian_population INTEGER,
hawaiian_population INTEGER,
other_population INTEGER,
male_population INTEGER,
female_population INTEGER,
median_age REAL,
male_median_age REAL,
female_median_age REAL,
residential_mailboxes INTEGER,
business_mailboxes INTEGER,
total_delivery_receptacles INTEGER,
businesses INTEGER,
"1st_quarter_payroll" INTEGER,
annual_payroll INTEGER,
employees INTEGER,
water_area REAL,
land_area REAL,
single_family_delivery_units INTEGER,
multi_family_delivery_units INTEGER,
total_beneficiaries INTEGER,
retired_workers INTEGER,
disabled_workers INTEGER,
parents_and_widowed INTEGER,
spouses INTEGER,
children INTEGER,
over_65 INTEGER,
monthly_benefits_all INTEGER,
monthly_benefits_retired_workers INTEGER,
monthly_benefits_widowed INTEGER,
CBSA INTEGER,
foreign key (state) references state(abbreviation),
foreign key (CBSA) references CBSA(CBSA)
);
CREATE TABLE alias
(
zip_code INTEGER
primary key,
alias TEXT,
foreign key (zip_code) references zip_data(zip_code)
);
CREATE TABLE area_code
(
zip_code INTEGER,
area_code INTEGER,
primary key (zip_code, area_code),
foreign key (zip_code) references zip_data(zip_code)
);
CREATE TABLE avoid
(
zip_code INTEGER,
bad_alias TEXT,
primary key (zip_code, bad_alias),
foreign key (zip_code) references zip_data(zip_code)
);
CREATE TABLE country
(
zip_code INTEGER,
county TEXT,
state TEXT,
primary key (zip_code, county),
foreign key (zip_code) references zip_data(zip_code),
foreign key (state) references state(abbreviation)
);
CREATE TABLE zip_congress
(
zip_code INTEGER,
district TEXT,
primary key (zip_code, district),
foreign key (district) references congress(cognress_rep_id),
foreign key (zip_code) references zip_data(zip_code)
);
|
language_corpus | How many words are there on the page titled "Asclepi"? | page titled "Asclepi" refers to title = 'Asclepi' ; | SELECT words FROM pages WHERE title = 'Asclepi' | 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;
|
works_cycles | Who is the sales person in charge of the territory with the id "9"? Provide their full name. | full name = FirstName+MiddleName+LastName; | SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.TerritoryID = 9 | 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
);
|
menu | What is the page count for menu with page ID of 130? | page ID of 130 refers MenuPage.id = 130; | SELECT T1.page_count FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id WHERE T2.id = 130 | CREATE TABLE Dish
(
id INTEGER
primary key,
name TEXT,
description TEXT,
menus_appeared INTEGER,
times_appeared INTEGER,
first_appeared INTEGER,
last_appeared INTEGER,
lowest_price REAL,
highest_price REAL
);
CREATE TABLE Menu
(
id INTEGER
primary key,
name TEXT,
sponsor TEXT,
event TEXT,
venue TEXT,
place TEXT,
physical_description TEXT,
occasion TEXT,
notes TEXT,
call_number TEXT,
keywords TEXT,
language TEXT,
date DATE,
location TEXT,
location_type TEXT,
currency TEXT,
currency_symbol TEXT,
status TEXT,
page_count INTEGER,
dish_count INTEGER
);
CREATE TABLE MenuPage
(
id INTEGER
primary key,
menu_id INTEGER,
page_number INTEGER,
image_id REAL,
full_height INTEGER,
full_width INTEGER,
uuid TEXT,
foreign key (menu_id) references Menu(id)
);
CREATE TABLE MenuItem
(
id INTEGER
primary key,
menu_page_id INTEGER,
price REAL,
high_price REAL,
dish_id INTEGER,
created_at TEXT,
updated_at TEXT,
xpos REAL,
ypos REAL,
foreign key (dish_id) references Dish(id),
foreign key (menu_page_id) references MenuPage(id)
);
|
movie_3 | How many rentals did Ella Oliver hire in June 2016? | 'Ella Oliver' is a full name of a customer; full name refers to first_name, last_name; rental hired in June 2016 refers to rental_date BETWEEN '2005-06-01' AND '2005-06-30' | SELECT COUNT(T1.rental_id) FROM rental AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'ELLA' AND T2.last_name = 'ELLA' AND date(T1.rental_date) BETWEEN '2005-06-01' AND '2005-06-30' | 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
);
|
regional_sales | Calculate the average net profit for bakeware product. | net profit can be computed as SUBTRACT(Unit Price, Unit Cost); AVG(net profit) where Product Name = 'Bakeware'; | SELECT AVG(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T2.`Product Name` = 'Bakeware' | CREATE TABLE Customers
(
CustomerID INTEGER
constraint Customers_pk
primary key,
"Customer Names" TEXT
);
CREATE TABLE Products
(
ProductID INTEGER
constraint Products_pk
primary key,
"Product Name" TEXT
);
CREATE TABLE Regions
(
StateCode TEXT
constraint Regions_pk
primary key,
State TEXT,
Region TEXT
);
CREATE TABLE IF NOT EXISTS "Sales Team"
(
SalesTeamID INTEGER
constraint "Sales Team_pk"
primary key,
"Sales Team" TEXT,
Region TEXT
);
CREATE TABLE IF NOT EXISTS "Store Locations"
(
StoreID INTEGER
constraint "Store Locations_pk"
primary key,
"City Name" TEXT,
County TEXT,
StateCode TEXT
constraint "Store Locations_Regions_StateCode_fk"
references Regions(StateCode),
State TEXT,
Type TEXT,
Latitude REAL,
Longitude REAL,
AreaCode INTEGER,
Population INTEGER,
"Household Income" INTEGER,
"Median Income" INTEGER,
"Land Area" INTEGER,
"Water Area" INTEGER,
"Time Zone" TEXT
);
CREATE TABLE IF NOT EXISTS "Sales Orders"
(
OrderNumber TEXT
constraint "Sales Orders_pk"
primary key,
"Sales Channel" TEXT,
WarehouseCode TEXT,
ProcuredDate TEXT,
OrderDate TEXT,
ShipDate TEXT,
DeliveryDate TEXT,
CurrencyCode TEXT,
_SalesTeamID INTEGER
constraint "Sales Orders_Sales Team_SalesTeamID_fk"
references "Sales Team"(SalesTeamID),
_CustomerID INTEGER
constraint "Sales Orders_Customers_CustomerID_fk"
references Customers(CustomerID),
_StoreID INTEGER
constraint "Sales Orders_Store Locations_StoreID_fk"
references "Store Locations"(StoreID),
_ProductID INTEGER
constraint "Sales Orders_Products_ProductID_fk"
references Products(ProductID),
"Order Quantity" INTEGER,
"Discount Applied" REAL,
"Unit Price" TEXT,
"Unit Cost" TEXT
);
|
student_loan | Mention the name of unemployed students who have never been absent from school. | have never been absent from school refers to month = 0 | SELECT T1.name FROM longest_absense_from_school AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.month = 0 | CREATE TABLE bool
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE person
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE disabled
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE enlist
(
"name" TEXT not null,
organ TEXT not null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
"name" TEXT default '' not null
primary key,
"month" INTEGER default 0 null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE male
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
"name" TEXT default '' not null
primary key,
bool TEXT null,
foreign key ("name") references person ("name")
on update cascade on delete cascade,
foreign key (bool) references bool ("name")
on update cascade on delete cascade
);
CREATE TABLE unemployed
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
`name` TEXT NOT NULL,
`school` TEXT NOT NULL,
`month` INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (`name`,`school`),
FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
|
language_corpus | What is the total pages of Wikipedia in Catalan language? | total pages refers to sum(pages); Catalan language refers to lang = 'ca' | SELECT pages FROM langs WHERE lang = 'ca' | 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;
|
movie | Please list the names of all the characters played by Tom Cruise. | played by Tom Cruise refers to name = 'Tom Cruise' | SELECT T1.`Character Name` FROM characters AS T1 INNER JOIN actor AS T2 ON T1.ActorID = T2.ActorID WHERE T2.Name = 'Tom Cruise' | CREATE TABLE actor
(
ActorID INTEGER
constraint actor_pk
primary key,
Name TEXT,
"Date of Birth" DATE,
"Birth City" TEXT,
"Birth Country" TEXT,
"Height (Inches)" INTEGER,
Biography TEXT,
Gender TEXT,
Ethnicity TEXT,
NetWorth TEXT
);
CREATE TABLE movie
(
MovieID INTEGER
constraint movie_pk
primary key,
Title TEXT,
"MPAA Rating" TEXT,
Budget INTEGER,
Gross INTEGER,
"Release Date" TEXT,
Genre TEXT,
Runtime INTEGER,
Rating REAL,
"Rating Count" INTEGER,
Summary TEXT
);
CREATE TABLE characters
(
MovieID INTEGER,
ActorID INTEGER,
"Character Name" TEXT,
creditOrder INTEGER,
pay TEXT,
screentime TEXT,
primary key (MovieID, ActorID),
foreign key (ActorID) references actor(ActorID),
foreign key (MovieID) references movie(MovieID)
);
|
synthea | Among the immunizations in 2017, calculate the percentage of patients who received the Influenza seasonal injectable preservative free. Among them, how many patients are English? | DIVIDE(COUNT(PATIENT when DESCRIPTION = 'Influenza seasonal injectable preservative free'), COUNT(PATIENT)) as percentage where strftime('%Y', 2017); English refers ethnicity = 'english'; | SELECT CAST(SUM(CASE WHEN T2.DESCRIPTION = 'Influenza seasonal injectable preservative free' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient), SUM(CASE WHEN T1.ethnicity = 'english' THEN 1 ELSE 0 END) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE strftime('%Y', T2.DATE) = '2017' | CREATE TABLE all_prevalences
(
ITEM TEXT
primary key,
"POPULATION TYPE" TEXT,
OCCURRENCES INTEGER,
"POPULATION COUNT" INTEGER,
"PREVALENCE RATE" REAL,
"PREVALENCE PERCENTAGE" REAL
);
CREATE TABLE patients
(
patient TEXT
primary key,
birthdate DATE,
deathdate DATE,
ssn TEXT,
drivers TEXT,
passport TEXT,
prefix TEXT,
first TEXT,
last TEXT,
suffix TEXT,
maiden TEXT,
marital TEXT,
race TEXT,
ethnicity TEXT,
gender TEXT,
birthplace TEXT,
address TEXT
);
CREATE TABLE encounters
(
ID TEXT
primary key,
DATE DATE,
PATIENT TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE allergies
(
START TEXT,
STOP TEXT,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE careplans
(
ID TEXT,
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE REAL,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE conditions
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient),
foreign key (DESCRIPTION) references all_prevalences(ITEM)
);
CREATE TABLE immunizations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (DATE, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE medications
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
primary key (START, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE observations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE TEXT,
DESCRIPTION TEXT,
VALUE REAL,
UNITS TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE procedures
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE IF NOT EXISTS "claims"
(
ID TEXT
primary key,
PATIENT TEXT
references patients,
BILLABLEPERIOD DATE,
ORGANIZATION TEXT,
ENCOUNTER TEXT
references encounters,
DIAGNOSIS TEXT,
TOTAL INTEGER
);
|
video_games | List the game IDs of the games produced by Abylight. | Abylight refers to publisher_name = 'Abylight'; | SELECT T1.game_id FROM game_publisher AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.id WHERE T2.publisher_name = 'Abylight' | CREATE TABLE genre
(
id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE game
(
id INTEGER not null
primary key,
genre_id INTEGER default NULL,
game_name TEXT default NULL,
foreign key (genre_id) references genre(id)
);
CREATE TABLE platform
(
id INTEGER not null
primary key,
platform_name TEXT default NULL
);
CREATE TABLE publisher
(
id INTEGER not null
primary key,
publisher_name TEXT default NULL
);
CREATE TABLE game_publisher
(
id INTEGER not null
primary key,
game_id INTEGER default NULL,
publisher_id INTEGER default NULL,
foreign key (game_id) references game(id),
foreign key (publisher_id) references publisher(id)
);
CREATE TABLE game_platform
(
id INTEGER not null
primary key,
game_publisher_id INTEGER default NULL,
platform_id INTEGER default NULL,
release_year INTEGER default NULL,
foreign key (game_publisher_id) references game_publisher(id),
foreign key (platform_id) references platform(id)
);
CREATE TABLE region
(
id INTEGER not null
primary key,
region_name TEXT default NULL
);
CREATE TABLE region_sales
(
region_id INTEGER default NULL,
game_platform_id INTEGER default NULL,
num_sales REAL default NULL,
foreign key (game_platform_id) references game_platform(id),
foreign key (region_id) references region(id)
);
|
olympics | Among the competitors of the 1994 Winter Olympic Game, what is the percentage of those from Finland? | DIVIDE(COUNT(id where region_name = 'Finland'), COUNT(id)) as percentage where games_name = '1994 Winter'; | SELECT CAST(COUNT(CASE WHEN T5.region_name = 'Finland' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T3.id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id INNER JOIN person_region AS T4 ON T3.id = T4.person_id INNER JOIN noc_region AS T5 ON T4.region_id = T5.id WHERE T1.games_name = '1994 Winter' | 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)
);
|
olympics | What is the name of the oldest competitor? | name refers to full_name; the oldest refers to MAX(age); | SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id ORDER BY T2.age DESC LIMIT 1 | 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)
);
|
shakespeare | How many chapters are there in "Midsummer Night's Dream"? | in "Midsummer Night's Dream" refers to Title = 'Midsummer Night's Dream' | SELECT COUNT(T2.id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Midsummer Night''s Dream' | CREATE TABLE IF NOT EXISTS "chapters"
(
id INTEGER
primary key autoincrement,
Act INTEGER not null,
Scene INTEGER not null,
Description TEXT not null,
work_id INTEGER not null
references works
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "characters"
(
id INTEGER
primary key autoincrement,
CharName TEXT not null,
Abbrev TEXT not null,
Description TEXT not null
);
CREATE TABLE IF NOT EXISTS "paragraphs"
(
id INTEGER
primary key autoincrement,
ParagraphNum INTEGER not null,
PlainText TEXT not null,
character_id INTEGER not null
references characters,
chapter_id INTEGER default 0 not null
references chapters
);
CREATE TABLE IF NOT EXISTS "works"
(
id INTEGER
primary key autoincrement,
Title TEXT not null,
LongTitle TEXT not null,
Date INTEGER not null,
GenreType TEXT not null
);
|
movie_3 | How many cities are there in the United States? | "United States" is the country | SELECT COUNT(T2.city) FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id WHERE T1.country = 'United States' | 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
);
|
food_inspection | Among the top 5 owners with highest number of establishments, which owner has the highest number of high risk violations? Give the name of the owner. | 5 owners with highest number of establishments refer to owner_name where MAX(COUNT(business_id)) LIMIT 5; the highest number of high risk violations refers to MAX(COUNT(risk_category = 'High Risk')); | SELECT T4.owner_name FROM violations AS T3 INNER JOIN businesses AS T4 ON T3.business_id = T4.business_id INNER JOIN ( SELECT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id GROUP BY T2.owner_name ORDER BY COUNT(T1.business_id) DESC LIMIT 5 ) AS T5 ON T4.owner_name = T5.owner_name WHERE T3.risk_category = 'High Risk' GROUP BY T4.owner_name ORDER BY COUNT(T3.risk_category) DESC LIMIT 1 | CREATE TABLE `businesses` (
`business_id` INTEGER NOT NULL,
`name` TEXT NOT NULL,
`address` TEXT DEFAULT NULL,
`city` TEXT DEFAULT NULL,
`postal_code` TEXT DEFAULT NULL,
`latitude` REAL DEFAULT NULL,
`longitude` REAL DEFAULT NULL,
`phone_number` INTEGER DEFAULT NULL,
`tax_code` TEXT DEFAULT NULL,
`business_certificate` INTEGER NOT NULL,
`application_date` DATE DEFAULT NULL,
`owner_name` TEXT NOT NULL,
`owner_address` TEXT DEFAULT NULL,
`owner_city` TEXT DEFAULT NULL,
`owner_state` TEXT DEFAULT NULL,
`owner_zip` TEXT DEFAULT NULL,
PRIMARY KEY (`business_id`)
);
CREATE TABLE `inspections` (
`business_id` INTEGER NOT NULL,
`score` INTEGER DEFAULT NULL,
`date` DATE NOT NULL,
`type` TEXT NOT NULL,
FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
);
CREATE TABLE `violations` (
`business_id` INTEGER NOT NULL,
`date` DATE NOT NULL,
`violation_type_id` TEXT NOT NULL,
`risk_category` TEXT NOT NULL,
`description` TEXT NOT NULL,
FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
);
|
synthea | What is the age of the patient with hypertension named Giovanni Russel? | age refers to SUBTRACT(strftime('%Y', deathdate), strftime('%Y', birthdate)); hypertension refers to conditions where DESCRIPTION = 'Hypertension'; | SELECT strftime('%Y', T2.deathdate) - strftime('%Y', T2.birthdate) AS age FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Giovanni' AND T2.last = 'Russel' AND T1.DESCRIPTION = 'Hypertension' | CREATE TABLE all_prevalences
(
ITEM TEXT
primary key,
"POPULATION TYPE" TEXT,
OCCURRENCES INTEGER,
"POPULATION COUNT" INTEGER,
"PREVALENCE RATE" REAL,
"PREVALENCE PERCENTAGE" REAL
);
CREATE TABLE patients
(
patient TEXT
primary key,
birthdate DATE,
deathdate DATE,
ssn TEXT,
drivers TEXT,
passport TEXT,
prefix TEXT,
first TEXT,
last TEXT,
suffix TEXT,
maiden TEXT,
marital TEXT,
race TEXT,
ethnicity TEXT,
gender TEXT,
birthplace TEXT,
address TEXT
);
CREATE TABLE encounters
(
ID TEXT
primary key,
DATE DATE,
PATIENT TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE allergies
(
START TEXT,
STOP TEXT,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE careplans
(
ID TEXT,
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE REAL,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE conditions
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient),
foreign key (DESCRIPTION) references all_prevalences(ITEM)
);
CREATE TABLE immunizations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (DATE, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE medications
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
primary key (START, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE observations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE TEXT,
DESCRIPTION TEXT,
VALUE REAL,
UNITS TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE procedures
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE IF NOT EXISTS "claims"
(
ID TEXT
primary key,
PATIENT TEXT
references patients,
BILLABLEPERIOD DATE,
ORGANIZATION TEXT,
ENCOUNTER TEXT
references encounters,
DIAGNOSIS TEXT,
TOTAL INTEGER
);
|
public_review_platform | How many users manage to get uber votes for all of the review category? Find out what are the user average star. | users refer to user_id; uber votes for all of the review category refer to review_votes_funny = 'uber' AND review_votes_useful = 'uber' AND review_votes_cool = 'uber'; | SELECT COUNT(T2.user_id) AS USER_IDS, T2.user_average_stars FROM Reviews AS T1 INNER JOIN Users AS T2 ON T1.user_id = T2.user_id WHERE T1.review_votes_funny = 'Uber' AND T1.review_votes_useful = 'Uber' AND T1.review_votes_cool = 'Uber' | 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
);
|
world_development_indicators | What's the agregation method for the indicator whose value is 133 in 1960 for the Arab World? | in 1960 refers to Year = 1960; for the Arab World refers to CountryName = 'Arab World' | SELECT T2.AggregationMethod FROM Indicators AS T1 INNER JOIN Series AS T2 ON T1.IndicatorName = T2.IndicatorName INNER JOIN Country AS T3 ON T1.CountryCode = T3.CountryCode WHERE T3.ShortName = 'Arab World' AND T1.Value = 133 AND T1.Year = 1960 | CREATE TABLE IF NOT EXISTS "Country"
(
CountryCode TEXT not null
primary key,
ShortName TEXT,
TableName TEXT,
LongName TEXT,
Alpha2Code TEXT,
CurrencyUnit TEXT,
SpecialNotes TEXT,
Region TEXT,
IncomeGroup TEXT,
Wb2Code TEXT,
NationalAccountsBaseYear TEXT,
NationalAccountsReferenceYear TEXT,
SnaPriceValuation TEXT,
LendingCategory TEXT,
OtherGroups TEXT,
SystemOfNationalAccounts TEXT,
AlternativeConversionFactor TEXT,
PppSurveyYear TEXT,
BalanceOfPaymentsManualInUse TEXT,
ExternalDebtReportingStatus TEXT,
SystemOfTrade TEXT,
GovernmentAccountingConcept TEXT,
ImfDataDisseminationStandard TEXT,
LatestPopulationCensus TEXT,
LatestHouseholdSurvey TEXT,
SourceOfMostRecentIncomeAndExpenditureData TEXT,
VitalRegistrationComplete TEXT,
LatestAgriculturalCensus TEXT,
LatestIndustrialData INTEGER,
LatestTradeData INTEGER,
LatestWaterWithdrawalData INTEGER
);
CREATE TABLE IF NOT EXISTS "Series"
(
SeriesCode TEXT not null
primary key,
Topic TEXT,
IndicatorName TEXT,
ShortDefinition TEXT,
LongDefinition TEXT,
UnitOfMeasure TEXT,
Periodicity TEXT,
BasePeriod TEXT,
OtherNotes INTEGER,
AggregationMethod TEXT,
LimitationsAndExceptions TEXT,
NotesFromOriginalSource TEXT,
GeneralComments TEXT,
Source TEXT,
StatisticalConceptAndMethodology TEXT,
DevelopmentRelevance TEXT,
RelatedSourceLinks TEXT,
OtherWebLinks INTEGER,
RelatedIndicators INTEGER,
LicenseType TEXT
);
CREATE TABLE CountryNotes
(
Countrycode TEXT NOT NULL ,
Seriescode TEXT NOT NULL ,
Description TEXT,
primary key (Countrycode, Seriescode),
FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Footnotes
(
Countrycode TEXT NOT NULL ,
Seriescode TEXT NOT NULL ,
Year TEXT,
Description TEXT,
primary key (Countrycode, Seriescode, Year),
FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Indicators
(
CountryName TEXT,
CountryCode TEXT NOT NULL ,
IndicatorName TEXT,
IndicatorCode TEXT NOT NULL ,
Year INTEGER NOT NULL ,
Value INTEGER,
primary key (CountryCode, IndicatorCode, Year),
FOREIGN KEY (CountryCode) REFERENCES Country(CountryCode)
);
CREATE TABLE SeriesNotes
(
Seriescode TEXT not null ,
Year TEXT not null ,
Description TEXT,
primary key (Seriescode, Year),
foreign key (Seriescode) references Series(SeriesCode)
);
|
food_inspection_2 | What is the risk level of the establishment that Bob Benson inspected? | SELECT DISTINCT T3.risk_level FROM employee AS T1 INNER JOIN inspection AS T2 ON T1.employee_id = T2.employee_id INNER JOIN establishment AS T3 ON T2.license_no = T3.license_no WHERE T1.first_name = 'Bob' AND T1.last_name = 'Benson' | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
license_no INTEGER
primary key,
dba_name TEXT,
aka_name TEXT,
facility_type TEXT,
risk_level INTEGER,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
latitude REAL,
longitude REAL,
ward INTEGER
);
CREATE TABLE inspection
(
inspection_id INTEGER
primary key,
inspection_date DATE,
inspection_type TEXT,
results TEXT,
employee_id INTEGER,
license_no INTEGER,
followup_to INTEGER,
foreign key (employee_id) references employee(employee_id),
foreign key (license_no) references establishment(license_no),
foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
point_id INTEGER
primary key,
Description TEXT,
category TEXT,
code TEXT,
fine INTEGER,
point_level TEXT
);
CREATE TABLE violation
(
inspection_id INTEGER,
point_id INTEGER,
fine INTEGER,
inspector_comment TEXT,
primary key (inspection_id, point_id),
foreign key (inspection_id) references inspection(inspection_id),
foreign key (point_id) references inspection_point(point_id)
);
|
|
image_and_language | Define the onion's bounding box on image no. 285930. | bounding box refers to (X, Y, W, H); onion refers to OBJ_CLASS = 'onion'; image no.285930 refers to IMG_ID = 285930 | SELECT T1.X, T1.Y, T1.W, T1.H FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID WHERE T1.IMG_ID = 285930 AND T2.OBJ_CLASS = 'onion' | CREATE TABLE ATT_CLASSES
(
ATT_CLASS_ID INTEGER default 0 not null
primary key,
ATT_CLASS TEXT not null
);
CREATE TABLE OBJ_CLASSES
(
OBJ_CLASS_ID INTEGER default 0 not null
primary key,
OBJ_CLASS TEXT not null
);
CREATE TABLE IMG_OBJ
(
IMG_ID INTEGER default 0 not null,
OBJ_SAMPLE_ID INTEGER default 0 not null,
OBJ_CLASS_ID INTEGER null,
X INTEGER null,
Y INTEGER null,
W INTEGER null,
H INTEGER null,
primary key (IMG_ID, OBJ_SAMPLE_ID),
foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID)
);
CREATE TABLE IMG_OBJ_ATT
(
IMG_ID INTEGER default 0 not null,
ATT_CLASS_ID INTEGER default 0 not null,
OBJ_SAMPLE_ID INTEGER default 0 not null,
primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID),
foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID),
foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
CREATE TABLE PRED_CLASSES
(
PRED_CLASS_ID INTEGER default 0 not null
primary key,
PRED_CLASS TEXT not null
);
CREATE TABLE IMG_REL
(
IMG_ID INTEGER default 0 not null,
PRED_CLASS_ID INTEGER default 0 not null,
OBJ1_SAMPLE_ID INTEGER default 0 not null,
OBJ2_SAMPLE_ID INTEGER default 0 not null,
primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID),
foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID),
foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID),
foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
|
food_inspection_2 | How many of the inspections with serious point levels have no fines? | serious point level refers to point_level = 'Serious'; no fines refers to fine = 0 | SELECT COUNT(DISTINCT T2.inspection_id) FROM inspection_point AS T1 INNER JOIN violation AS T2 ON T1.point_id = T2.point_id WHERE T1.point_level = 'Serious ' AND T2.fine = 0 | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
license_no INTEGER
primary key,
dba_name TEXT,
aka_name TEXT,
facility_type TEXT,
risk_level INTEGER,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
latitude REAL,
longitude REAL,
ward INTEGER
);
CREATE TABLE inspection
(
inspection_id INTEGER
primary key,
inspection_date DATE,
inspection_type TEXT,
results TEXT,
employee_id INTEGER,
license_no INTEGER,
followup_to INTEGER,
foreign key (employee_id) references employee(employee_id),
foreign key (license_no) references establishment(license_no),
foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
point_id INTEGER
primary key,
Description TEXT,
category TEXT,
code TEXT,
fine INTEGER,
point_level TEXT
);
CREATE TABLE violation
(
inspection_id INTEGER,
point_id INTEGER,
fine INTEGER,
inspector_comment TEXT,
primary key (inspection_id, point_id),
foreign key (inspection_id) references inspection(inspection_id),
foreign key (point_id) references inspection_point(point_id)
);
|
sales_in_weather | What was the temperature range of station no.1 on 2012/1/1? | on 2012/1/1 refers to date = '2012-01-01'; temperature range refers to Subtract (tmax, tmin); station no.1 refers to station_nbr = 1 | SELECT tmax - tmin AS temrange FROM weather WHERE station_nbr = 1 AND `date` = '2012-01-01' | CREATE TABLE sales_in_weather
(
date DATE,
store_nbr INTEGER,
item_nbr INTEGER,
units INTEGER,
primary key (store_nbr, date, item_nbr)
);
CREATE TABLE weather
(
station_nbr INTEGER,
date DATE,
tmax INTEGER,
tmin INTEGER,
tavg INTEGER,
depart INTEGER,
dewpoint INTEGER,
wetbulb INTEGER,
heat INTEGER,
cool INTEGER,
sunrise TEXT,
sunset TEXT,
codesum TEXT,
snowfall REAL,
preciptotal REAL,
stnpressure REAL,
sealevel REAL,
resultspeed REAL,
resultdir INTEGER,
avgspeed REAL,
primary key (station_nbr, date)
);
CREATE TABLE relation
(
store_nbr INTEGER
primary key,
station_nbr INTEGER,
foreign key (store_nbr) references sales_in_weather(store_nbr),
foreign key (station_nbr) references weather(station_nbr)
);
|
retails | List the country name of the customers in the building marketing segment with an account balance greater than 80% of the average account balance of all customers. | country name refers to n_name; building marketing segment refers to c_mktsegment = 'BUILDING'; account balance greater than 80% of the average account balance of all customers refers to c_acctbal > MULTIPLY(AVG(c_acctbal), 0.8); | SELECT T2.n_name FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey INNER JOIN ( SELECT AVG(c_acctbal) * 0.8 AS avg_acctbal FROM customer ) AS T3 WHERE T1.c_acctbal > T3.avg_acctbal | 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)
);
|
cars | Provide the ID of cars from Japan worth greater than 35000 and have an acceleration of 14. | from Japan refers to country = 'Japan'; worth greater than 35000 refers to price > 35000; have an acceleration of 14 refers to acceleration = 14 | SELECT T4.ID FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'Japan' AND T1.price > 3500 AND T4.acceleration = 14 | CREATE TABLE country
(
origin INTEGER
primary key,
country TEXT
);
CREATE TABLE price
(
ID INTEGER
primary key,
price REAL
);
CREATE TABLE data
(
ID INTEGER
primary key,
mpg REAL,
cylinders INTEGER,
displacement REAL,
horsepower INTEGER,
weight INTEGER,
acceleration REAL,
model INTEGER,
car_name TEXT,
foreign key (ID) references price(ID)
);
CREATE TABLE production
(
ID INTEGER,
model_year INTEGER,
country INTEGER,
primary key (ID, model_year),
foreign key (country) references country(origin),
foreign key (ID) references data(ID),
foreign key (ID) references price(ID)
);
|
authors | Identify by publication year in the paper database all journals that don't have short name. | don't have short name refers to ShortName is NULL OR ShortName = '' | SELECT DISTINCT T2.Year, FullName FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T1.ShortName = '' | 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)
);
|
mental_health_survey | Provide the number of users who took part in the "mental health survey for 2016". | mental health survey for 2016 refers to SurveyID = 2016 | SELECT COUNT(DISTINCT T1.UserID) FROM Answer AS T1 INNER JOIN Survey AS T2 ON T1.SurveyID = T2.SurveyID WHERE T2.Description = 'mental health survey for 2016' | 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)
);
|
music_platform_2 | What dates were the Don't Lie To Your Life Coach podcast reviews created? | "Don't Lie To Your Life Coach" refers to title of podcast; date refers to created_at | SELECT created_at FROM reviews WHERE podcast_id = ( SELECT podcast_id FROM podcasts WHERE title = 'Don''t Lie To Your Life Coach' ) | 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);
|
sales | How many free or gift products are there? | free gift refers to Price = 0; | SELECT COUNT(ProductID) FROM Products WHERE Price = 0 | 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
);
|
student_loan | Which male students are unemployed, disable and were absent for 5 month? | male students are mentioned in male.name; unemployed and disabled refers to unemployed.name = disabled.name; absent for 5 month refers to month = 5; | SELECT T1.name FROM unemployed AS T1 INNER JOIN disabled AS T2 ON T2.name = T1.name INNER JOIN longest_absense_from_school AS T3 ON T3.name = T2.name WHERE T3.month = 5 | CREATE TABLE bool
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE person
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE disabled
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE enlist
(
"name" TEXT not null,
organ TEXT not null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
"name" TEXT default '' not null
primary key,
"month" INTEGER default 0 null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE male
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
"name" TEXT default '' not null
primary key,
bool TEXT null,
foreign key ("name") references person ("name")
on update cascade on delete cascade,
foreign key (bool) references bool ("name")
on update cascade on delete cascade
);
CREATE TABLE unemployed
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
`name` TEXT NOT NULL,
`school` TEXT NOT NULL,
`month` INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (`name`,`school`),
FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
|
food_inspection_2 | Provide the names and locations of the facilities that failed inspections on 29th July 2013. | name refers to dba_name; location refers to latitude, longitude; failed inspections refers to results = 'Fail'; on 29th July 2013 refers to inspection_date = '2013-07-29' | SELECT T2.dba_name, T2.longitude, T2.latitude FROM inspection AS T1 INNER JOIN establishment AS T2 ON T1.license_no = T2.license_no WHERE T1.inspection_date = '2013-07-29' AND T1.results = 'Fail' | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
license_no INTEGER
primary key,
dba_name TEXT,
aka_name TEXT,
facility_type TEXT,
risk_level INTEGER,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
latitude REAL,
longitude REAL,
ward INTEGER
);
CREATE TABLE inspection
(
inspection_id INTEGER
primary key,
inspection_date DATE,
inspection_type TEXT,
results TEXT,
employee_id INTEGER,
license_no INTEGER,
followup_to INTEGER,
foreign key (employee_id) references employee(employee_id),
foreign key (license_no) references establishment(license_no),
foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
point_id INTEGER
primary key,
Description TEXT,
category TEXT,
code TEXT,
fine INTEGER,
point_level TEXT
);
CREATE TABLE violation
(
inspection_id INTEGER,
point_id INTEGER,
fine INTEGER,
inspector_comment TEXT,
primary key (inspection_id, point_id),
foreign key (inspection_id) references inspection(inspection_id),
foreign key (point_id) references inspection_point(point_id)
);
|
computer_student | List the ID of all professors who are not faculty member along with the courses taught by him/her. | ID of all professors refers to person.p_id where professor = 1; not faculty member refers to hasPosition = 0; courses refers to taughtBy.course_id | SELECT T2.p_id, T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition <> 0 | CREATE TABLE course
(
course_id INTEGER
constraint course_pk
primary key,
courseLevel TEXT
);
CREATE TABLE person
(
p_id INTEGER
constraint person_pk
primary key,
professor INTEGER,
student INTEGER,
hasPosition TEXT,
inPhase TEXT,
yearsInProgram TEXT
);
CREATE TABLE IF NOT EXISTS "advisedBy"
(
p_id INTEGER,
p_id_dummy INTEGER,
constraint advisedBy_pk
primary key (p_id, p_id_dummy),
constraint advisedBy_person_p_id_p_id_fk
foreign key (p_id, p_id_dummy) references person (p_id, p_id)
);
CREATE TABLE taughtBy
(
course_id INTEGER,
p_id INTEGER,
primary key (course_id, p_id),
foreign key (p_id) references person(p_id),
foreign key (course_id) references course(course_id)
);
|
codebase_comments | How many solution paths are there inside the 2nd most popular repository? | more watchers mean that this repository is more popular; most popular repository refers to max(Watchers); | SELECT COUNT(DISTINCT T2.Path) FROM Repo AS T1 INNER JOIN Solution AS T2 ON T1.Id = T2.RepoId WHERE T1.Watchers = ( SELECT Watchers FROM Repo ORDER BY Watchers DESC LIMIT 1, 1 ) | 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
);
|
app_store | How many negative comments are there in all the apps with 100,000,000+ installs? | negative comment refers to Sentiment = 'Negative'; Installs = '100,000,000+'; | SELECT COUNT(T2.Sentiment) FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.Installs = '100,000,000+' AND T2.Sentiment = 'Negative' | CREATE TABLE IF NOT EXISTS "playstore"
(
App TEXT,
Category TEXT,
Rating REAL,
Reviews INTEGER,
Size TEXT,
Installs TEXT,
Type TEXT,
Price TEXT,
"Content Rating" TEXT,
Genres TEXT
);
CREATE TABLE IF NOT EXISTS "user_reviews"
(
App TEXT
references "playstore" (App),
Translated_Review TEXT,
Sentiment TEXT,
Sentiment_Polarity TEXT,
Sentiment_Subjectivity TEXT
);
|
university | Calculate the average score of university ID 79 between year 2013 to 2015. | average score refers to avg(score); between year 2013 to 2015 refers to year BETWEEN 2013 AND 2015 | SELECT AVG(score) FROM university_ranking_year WHERE year BETWEEN 2013 AND 2015 AND university_id = 79 | CREATE TABLE country
(
id INTEGER not null
primary key,
country_name TEXT default NULL
);
CREATE TABLE ranking_system
(
id INTEGER not null
primary key,
system_name TEXT default NULL
);
CREATE TABLE ranking_criteria
(
id INTEGER not null
primary key,
ranking_system_id INTEGER default NULL,
criteria_name TEXT default NULL,
foreign key (ranking_system_id) references ranking_system(id)
);
CREATE TABLE university
(
id INTEGER not null
primary key,
country_id INTEGER default NULL,
university_name TEXT default NULL,
foreign key (country_id) references country(id)
);
CREATE TABLE university_ranking_year
(
university_id INTEGER default NULL,
ranking_criteria_id INTEGER default NULL,
year INTEGER default NULL,
score INTEGER default NULL,
foreign key (ranking_criteria_id) references ranking_criteria(id),
foreign key (university_id) references university(id)
);
CREATE TABLE university_year
(
university_id INTEGER default NULL,
year INTEGER default NULL,
num_students INTEGER default NULL,
student_staff_ratio REAL default NULL,
pct_international_students INTEGER default NULL,
pct_female_students INTEGER default NULL,
foreign key (university_id) references university(id)
);
|
hockey | State the nick name of player ID 'aubinje01'. List all the teams and season he played for. | nick name refers to nameNick; team refers to tmID; season refers to year
| SELECT DISTINCT T1.nameNick, T3.year, T3.name FROM Master AS T1 INNER JOIN Goalies AS T2 ON T1.playerID = T2.playerID INNER JOIN Teams AS T3 ON T2.tmID = T3.tmID WHERE T1.playerID = 'aubinje01' | 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)
);
|
trains | List all the directions of the trains that have empty cars. | empty cars refers to load_num = 0 | SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.load_num = 0 | CREATE TABLE `cars` (
`id` INTEGER NOT NULL,
`train_id` INTEGER DEFAULT NULL,
`position` INTEGER DEFAULT NULL,
`shape` TEXT DEFAULT NULL,
`len`TEXT DEFAULT NULL,
`sides` TEXT DEFAULT NULL,
`roof` TEXT DEFAULT NULL,
`wheels` INTEGER DEFAULT NULL,
`load_shape` TEXT DEFAULT NULL,
`load_num` INTEGER DEFAULT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`train_id`) REFERENCES `trains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `trains` (
`id` INTEGER NOT NULL,
`direction` TEXT DEFAULT NULL,
PRIMARY KEY (`id`)
);
|
authors | Which journal was the paper "Education, democracy and growth" published on? Give the full name of the journal. | 'Education, democracy and growth' is the title of a paper | SELECT T1.FullName FROM Journal AS T1 INNER JOIN Paper AS T2 ON T1.Id = T2.JournalId WHERE T2.Title = 'Education, democracy and growth' | 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)
);
|
retails | How many orders in 1998 had a total price under 950? | 1998 refers to year(o_orderdate) = '1998'; a total price under 950 refers to o_totalprice < 950 | SELECT COUNT(o_orderkey) AS countorders FROM orders WHERE STRFTIME('%Y', o_orderdate) = '1998' AND o_totalprice < 950 | 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)
);
|
works_cycles | Name all products and total quantity for each item for shopping cart ID 14951. | SELECT T1.Name, T2.Quantity FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 14951 | 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
);
|
|
movie_3 | What is the percentage of horror film titles in English film titles? | horror film refers to category.name = 'Horror'; English film refers to language.name = 'English'; percentage = divide(count(film_id where category.name = 'Horror'), count(film_id)) where language.name = 'English' * 100% | SELECT CAST(SUM(IIF(T3.name = 'Horror', 1, 0)) AS REAL) * 100 / COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN film AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T1.category_id = T3.category_id INNER JOIN language AS T4 ON T2.language_id = T4.language_id WHERE T4.name = 'English' | 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
);
|
european_football_1 | How many Scottish League One games took place on the day that "Pro Vercelli" and "Pescara"had a 5-2 game? | Pro Vercelli and Pescara are names of teams; HomeTeam = 'Pro Vercelli'; AwayTeam = 'Pescara'; 5-2 is a score where FTHG = '5' and FTAG = '2'; Scottish League One is a name of division; games refer to Div; | SELECT COUNT(T1.Date) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Scottish League One' AND T1.Date = ( SELECT Date FROM matchs WHERE FTHG = 5 AND FTAG = 2 AND HomeTeam = 'Pro Vercelli' AND AwayTeam = 'Pescara' ) | CREATE TABLE divisions
(
division TEXT not null
primary key,
name TEXT,
country TEXT
);
CREATE TABLE matchs
(
Div TEXT,
Date DATE,
HomeTeam TEXT,
AwayTeam TEXT,
FTHG INTEGER,
FTAG INTEGER,
FTR TEXT,
season INTEGER,
foreign key (Div) references divisions(division)
);
|
mondial_geo | Which two nations are separated from one another by the longest border? Please include the entire names of the nations in your answer. | SELECT Country1, Country2 FROM borders ORDER BY Length DESC LIMIT 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
);
|
|
professional_basketball | Among the Most improved Players awarded from 1985-1990, how many player whose country is USA? | the Most improved Player refers to award = 'Most Improved Player'; from 1985-1990 refers to year between 1985 and 1990; country is USA refers to birthCountry = 'USA' | SELECT COUNT(DISTINCT T2.playerID) FROM awards_players AS T1 INNER JOIN players AS T2 ON T1.playerID = T2.playerID WHERE T1.award = 'Most Improved Player' AND T2.birthCountry = 'USA' AND T1.year BETWEEN 1985 AND 1990 | CREATE TABLE awards_players
(
playerID TEXT not null,
award TEXT not null,
year INTEGER not null,
lgID TEXT null,
note TEXT null,
pos TEXT null,
primary key (playerID, year, award),
foreign key (playerID) references players (playerID)
on update cascade on delete cascade
);
CREATE TABLE coaches
(
coachID TEXT not null,
year INTEGER not null,
tmID TEXT not null,
lgID TEXT null,
stint INTEGER not null,
won INTEGER null,
lost INTEGER null,
post_wins INTEGER null,
post_losses INTEGER null,
primary key (coachID, year, tmID, stint),
foreign key (tmID, year) references teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE draft
(
id INTEGER default 0 not null
primary key,
draftYear INTEGER null,
draftRound INTEGER null,
draftSelection INTEGER null,
draftOverall INTEGER null,
tmID TEXT null,
firstName TEXT null,
lastName TEXT null,
suffixName TEXT null,
playerID TEXT null,
draftFrom TEXT null,
lgID TEXT null,
foreign key (tmID, draftYear) references teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE player_allstar
(
playerID TEXT not null,
last_name TEXT null,
first_name TEXT null,
season_id INTEGER not null,
conference TEXT null,
league_id TEXT null,
games_played INTEGER null,
minutes INTEGER null,
points INTEGER null,
o_rebounds INTEGER null,
d_rebounds INTEGER null,
rebounds INTEGER null,
assists INTEGER null,
steals INTEGER null,
blocks INTEGER null,
turnovers INTEGER null,
personal_fouls INTEGER null,
fg_attempted INTEGER null,
fg_made INTEGER null,
ft_attempted INTEGER null,
ft_made INTEGER null,
three_attempted INTEGER null,
three_made INTEGER null,
primary key (playerID, season_id),
foreign key (playerID) references players (playerID)
on update cascade on delete cascade
);
CREATE TABLE players
(
playerID TEXT not null
primary key,
useFirst TEXT null,
firstName TEXT null,
middleName TEXT null,
lastName TEXT null,
nameGiven TEXT null,
fullGivenName TEXT null,
nameSuffix TEXT null,
nameNick TEXT null,
pos TEXT null,
firstseason INTEGER null,
lastseason INTEGER null,
height REAL null,
weight INTEGER null,
college TEXT null,
collegeOther TEXT null,
birthDate DATE null,
birthCity TEXT null,
birthState TEXT null,
birthCountry TEXT null,
highSchool TEXT null,
hsCity TEXT null,
hsState TEXT null,
hsCountry TEXT null,
deathDate DATE null,
race TEXT null
);
CREATE TABLE teams
(
year INTEGER not null,
lgID TEXT null,
tmID TEXT not null,
franchID TEXT null,
confID TEXT null,
divID TEXT null,
`rank` INTEGER null,
confRank INTEGER null,
playoff TEXT null,
name TEXT null,
o_fgm INTEGER null,
-- o_fga int null,
o_ftm INTEGER null,
-- o_fta int null,
-- o_3pm int null,
-- o_3pa int null,
-- o_oreb int null,
-- o_dreb int null,
-- o_reb int null,
-- o_asts int null,
-- o_pf int null,
-- o_stl int null,
-- o_to int null,
-- o_blk int null,
o_pts INTEGER null,
-- d_fgm int null,
-- d_fga int null,
-- d_ftm int null,
-- d_fta int null,
-- d_3pm int null,
-- d_3pa int null,
-- d_oreb int null,
-- d_dreb int null,
-- d_reb int null,
-- d_asts int null,
-- d_pf int null,
-- d_stl int null,
-- d_to int null,
-- d_blk int null,
d_pts INTEGER null,
-- o_tmRebound int null,
-- d_tmRebound int null,
homeWon INTEGER null,
homeLost INTEGER null,
awayWon INTEGER null,
awayLost INTEGER null,
-- neutWon int null,
-- neutLoss int null,
-- confWon int null,
-- confLoss int null,
-- divWon int null,
-- divLoss int null,
-- pace int null,
won INTEGER null,
lost INTEGER null,
games INTEGER null,
-- min int null,
arena TEXT null,
-- attendance int null,
-- bbtmID varchar(255) null,
primary key (year, tmID)
);
CREATE TABLE IF NOT EXISTS "awards_coaches"
(
id INTEGER
primary key autoincrement,
year INTEGER,
coachID TEXT,
award TEXT,
lgID TEXT,
note TEXT,
foreign key (coachID, year) references coaches (coachID, year)
on update cascade on delete cascade
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "players_teams"
(
id INTEGER
primary key autoincrement,
playerID TEXT not null
references players
on update cascade on delete cascade,
year INTEGER,
stint INTEGER,
tmID TEXT,
lgID TEXT,
GP INTEGER,
GS INTEGER,
minutes INTEGER,
points INTEGER,
oRebounds INTEGER,
dRebounds INTEGER,
rebounds INTEGER,
assists INTEGER,
steals INTEGER,
blocks INTEGER,
turnovers INTEGER,
PF INTEGER,
fgAttempted INTEGER,
fgMade INTEGER,
ftAttempted INTEGER,
ftMade INTEGER,
threeAttempted INTEGER,
threeMade INTEGER,
PostGP INTEGER,
PostGS INTEGER,
PostMinutes INTEGER,
PostPoints INTEGER,
PostoRebounds INTEGER,
PostdRebounds INTEGER,
PostRebounds INTEGER,
PostAssists INTEGER,
PostSteals INTEGER,
PostBlocks INTEGER,
PostTurnovers INTEGER,
PostPF INTEGER,
PostfgAttempted INTEGER,
PostfgMade INTEGER,
PostftAttempted INTEGER,
PostftMade INTEGER,
PostthreeAttempted INTEGER,
PostthreeMade INTEGER,
note TEXT,
foreign key (tmID, year) references teams (tmID, year)
on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "series_post"
(
id INTEGER
primary key autoincrement,
year INTEGER,
round TEXT,
series TEXT,
tmIDWinner TEXT,
lgIDWinner TEXT,
tmIDLoser TEXT,
lgIDLoser TEXT,
W INTEGER,
L INTEGER,
foreign key (tmIDWinner, year) references teams (tmID, year)
on update cascade on delete cascade,
foreign key (tmIDLoser, year) references teams (tmID, year)
on update cascade on delete cascade
);
|
soccer_2016 | Tally the player IDs of "Man of the Series" awardees for the seasons from 2011 to 2015. | seasons from 2011 to 2015 refers to 2011 < Season_Year < 2015 | SELECT Man_of_the_Series FROM Season WHERE 2011 < Season_Year < 2015 | CREATE TABLE Batting_Style
(
Batting_Id INTEGER
primary key,
Batting_hand TEXT
);
CREATE TABLE Bowling_Style
(
Bowling_Id INTEGER
primary key,
Bowling_skill TEXT
);
CREATE TABLE City
(
City_Id INTEGER
primary key,
City_Name TEXT,
Country_id INTEGER
);
CREATE TABLE Country
(
Country_Id INTEGER
primary key,
Country_Name TEXT,
foreign key (Country_Id) references Country(Country_Id)
);
CREATE TABLE Extra_Type
(
Extra_Id INTEGER
primary key,
Extra_Name TEXT
);
CREATE TABLE Extra_Runs
(
Match_Id INTEGER,
Over_Id INTEGER,
Ball_Id INTEGER,
Extra_Type_Id INTEGER,
Extra_Runs INTEGER,
Innings_No INTEGER,
primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
foreign key (Extra_Type_Id) references Extra_Type(Extra_Id)
);
CREATE TABLE Out_Type
(
Out_Id INTEGER
primary key,
Out_Name TEXT
);
CREATE TABLE Outcome
(
Outcome_Id INTEGER
primary key,
Outcome_Type TEXT
);
CREATE TABLE Player
(
Player_Id INTEGER
primary key,
Player_Name TEXT,
DOB DATE,
Batting_hand INTEGER,
Bowling_skill INTEGER,
Country_Name INTEGER,
foreign key (Batting_hand) references Batting_Style(Batting_Id),
foreign key (Bowling_skill) references Bowling_Style(Bowling_Id),
foreign key (Country_Name) references Country(Country_Id)
);
CREATE TABLE Rolee
(
Role_Id INTEGER
primary key,
Role_Desc TEXT
);
CREATE TABLE Season
(
Season_Id INTEGER
primary key,
Man_of_the_Series INTEGER,
Orange_Cap INTEGER,
Purple_Cap INTEGER,
Season_Year INTEGER
);
CREATE TABLE Team
(
Team_Id INTEGER
primary key,
Team_Name TEXT
);
CREATE TABLE Toss_Decision
(
Toss_Id INTEGER
primary key,
Toss_Name TEXT
);
CREATE TABLE Umpire
(
Umpire_Id INTEGER
primary key,
Umpire_Name TEXT,
Umpire_Country INTEGER,
foreign key (Umpire_Country) references Country(Country_Id)
);
CREATE TABLE Venue
(
Venue_Id INTEGER
primary key,
Venue_Name TEXT,
City_Id INTEGER,
foreign key (City_Id) references City(City_Id)
);
CREATE TABLE Win_By
(
Win_Id INTEGER
primary key,
Win_Type TEXT
);
CREATE TABLE Match
(
Match_Id INTEGER
primary key,
Team_1 INTEGER,
Team_2 INTEGER,
Match_Date DATE,
Season_Id INTEGER,
Venue_Id INTEGER,
Toss_Winner INTEGER,
Toss_Decide INTEGER,
Win_Type INTEGER,
Win_Margin INTEGER,
Outcome_type INTEGER,
Match_Winner INTEGER,
Man_of_the_Match INTEGER,
foreign key (Team_1) references Team(Team_Id),
foreign key (Team_2) references Team(Team_Id),
foreign key (Season_Id) references Season(Season_Id),
foreign key (Venue_Id) references Venue(Venue_Id),
foreign key (Toss_Winner) references Team(Team_Id),
foreign key (Toss_Decide) references Toss_Decision(Toss_Id),
foreign key (Win_Type) references Win_By(Win_Id),
foreign key (Outcome_type) references Out_Type(Out_Id),
foreign key (Match_Winner) references Team(Team_Id),
foreign key (Man_of_the_Match) references Player(Player_Id)
);
CREATE TABLE Ball_by_Ball
(
Match_Id INTEGER,
Over_Id INTEGER,
Ball_Id INTEGER,
Innings_No INTEGER,
Team_Batting INTEGER,
Team_Bowling INTEGER,
Striker_Batting_Position INTEGER,
Striker INTEGER,
Non_Striker INTEGER,
Bowler INTEGER,
primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
foreign key (Match_Id) references Match(Match_Id)
);
CREATE TABLE Batsman_Scored
(
Match_Id INTEGER,
Over_Id INTEGER,
Ball_Id INTEGER,
Runs_Scored INTEGER,
Innings_No INTEGER,
primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
foreign key (Match_Id) references Match(Match_Id)
);
CREATE TABLE Player_Match
(
Match_Id INTEGER,
Player_Id INTEGER,
Role_Id INTEGER,
Team_Id INTEGER,
primary key (Match_Id, Player_Id, Role_Id),
foreign key (Match_Id) references Match(Match_Id),
foreign key (Player_Id) references Player(Player_Id),
foreign key (Team_Id) references Team(Team_Id),
foreign key (Role_Id) references Rolee(Role_Id)
);
CREATE TABLE Wicket_Taken
(
Match_Id INTEGER,
Over_Id INTEGER,
Ball_Id INTEGER,
Player_Out INTEGER,
Kind_Out INTEGER,
Fielders INTEGER,
Innings_No INTEGER,
primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
foreign key (Match_Id) references Match(Match_Id),
foreign key (Player_Out) references Player(Player_Id),
foreign key (Kind_Out) references Out_Type(Out_Id),
foreign key (Fielders) references Player(Player_Id)
);
|
movielens | What is the proportion of action movies directors who are called 'box office success paradox'? | 'box office success paradox' means average revenue exceeds their quality; The proportion can be computed by [(avg_revenue > d_quality) / ()] * 100% | SELECT CAST(SUM(IIF(T2.avg_revenue > T2.d_quality, 1, 0)) AS REAL) * 100 / COUNT(T1.movieid) FROM movies2directors AS T1 INNER JOIN directors AS T2 ON T1.directorid = T2.directorid WHERE T1.genre = 'Action' | 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)
);
|
address | What is the total number of households in Arecibo county? | "ARECIBO" is the county; total number of households refer to sum(households) | SELECT SUM(T1.households) FROM zip_data AS T1 INNER JOIN country AS T2 ON T1.zip_code = T2.zip_code WHERE T2.county = 'ARECIBO' | CREATE TABLE CBSA
(
CBSA INTEGER
primary key,
CBSA_name TEXT,
CBSA_type TEXT
);
CREATE TABLE state
(
abbreviation TEXT
primary key,
name TEXT
);
CREATE TABLE congress
(
cognress_rep_id TEXT
primary key,
first_name TEXT,
last_name TEXT,
CID TEXT,
party TEXT,
state TEXT,
abbreviation TEXT,
House TEXT,
District INTEGER,
land_area REAL,
foreign key (abbreviation) references state(abbreviation)
);
CREATE TABLE zip_data
(
zip_code INTEGER
primary key,
city TEXT,
state TEXT,
multi_county TEXT,
type TEXT,
organization TEXT,
time_zone TEXT,
daylight_savings TEXT,
latitude REAL,
longitude REAL,
elevation INTEGER,
state_fips INTEGER,
county_fips INTEGER,
region TEXT,
division TEXT,
population_2020 INTEGER,
population_2010 INTEGER,
households INTEGER,
avg_house_value INTEGER,
avg_income_per_household INTEGER,
persons_per_household REAL,
white_population INTEGER,
black_population INTEGER,
hispanic_population INTEGER,
asian_population INTEGER,
american_indian_population INTEGER,
hawaiian_population INTEGER,
other_population INTEGER,
male_population INTEGER,
female_population INTEGER,
median_age REAL,
male_median_age REAL,
female_median_age REAL,
residential_mailboxes INTEGER,
business_mailboxes INTEGER,
total_delivery_receptacles INTEGER,
businesses INTEGER,
"1st_quarter_payroll" INTEGER,
annual_payroll INTEGER,
employees INTEGER,
water_area REAL,
land_area REAL,
single_family_delivery_units INTEGER,
multi_family_delivery_units INTEGER,
total_beneficiaries INTEGER,
retired_workers INTEGER,
disabled_workers INTEGER,
parents_and_widowed INTEGER,
spouses INTEGER,
children INTEGER,
over_65 INTEGER,
monthly_benefits_all INTEGER,
monthly_benefits_retired_workers INTEGER,
monthly_benefits_widowed INTEGER,
CBSA INTEGER,
foreign key (state) references state(abbreviation),
foreign key (CBSA) references CBSA(CBSA)
);
CREATE TABLE alias
(
zip_code INTEGER
primary key,
alias TEXT,
foreign key (zip_code) references zip_data(zip_code)
);
CREATE TABLE area_code
(
zip_code INTEGER,
area_code INTEGER,
primary key (zip_code, area_code),
foreign key (zip_code) references zip_data(zip_code)
);
CREATE TABLE avoid
(
zip_code INTEGER,
bad_alias TEXT,
primary key (zip_code, bad_alias),
foreign key (zip_code) references zip_data(zip_code)
);
CREATE TABLE country
(
zip_code INTEGER,
county TEXT,
state TEXT,
primary key (zip_code, county),
foreign key (zip_code) references zip_data(zip_code),
foreign key (state) references state(abbreviation)
);
CREATE TABLE zip_congress
(
zip_code INTEGER,
district TEXT,
primary key (zip_code, district),
foreign key (district) references congress(cognress_rep_id),
foreign key (zip_code) references zip_data(zip_code)
);
|
public_review_platform | Which business ID have the shortest business operating hours? | the shortest business operating hours refer to MIN(SUBTRACT(closing_time, opening_time)); | SELECT business_id FROM Business_Hours ORDER BY closing_time - opening_time LIMIT 1 | 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
);
|
coinmarketcap | How much dollars was a Bitcoin worth on 2013/4/28 according to the coin market? | worth refers to price; on 2013/4/28 refers to date = '2013-04-28' | SELECT T2.market_cap FROM coins AS T1 INNER JOIN historical AS T2 ON T1.id = T2.coin_id WHERE T2.date = '2013-04-28' AND T1.name = 'Bitcoin' | CREATE TABLE coins
(
id INTEGER not null
primary key,
name TEXT,
slug TEXT,
symbol TEXT,
status TEXT,
category TEXT,
description TEXT,
subreddit TEXT,
notice TEXT,
tags TEXT,
tag_names TEXT,
website TEXT,
platform_id INTEGER,
date_added TEXT,
date_launched TEXT
);
CREATE TABLE IF NOT EXISTS "historical"
(
date DATE,
coin_id INTEGER,
cmc_rank INTEGER,
market_cap REAL,
price REAL,
open REAL,
high REAL,
low REAL,
close REAL,
time_high TEXT,
time_low TEXT,
volume_24h REAL,
percent_change_1h REAL,
percent_change_24h REAL,
percent_change_7d REAL,
circulating_supply REAL,
total_supply REAL,
max_supply REAL,
num_market_pairs INTEGER
);
|
retails | How many items were shipped on 4th December, 1993? | items shipped on 4th December, 1993 refer to l_linenumber where l_shipdate = '1993-12-04'; | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipdate = '1993-12-04' | 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)
);
|
synthea | Write down the Social Security numbers of patients who have latex allergies. | Social Security numbers refers to ssn; latex allergies refers to allergies.DESCRIPTION = 'Latex allergy'; | SELECT T1.ssn FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Latex allergy' | CREATE TABLE all_prevalences
(
ITEM TEXT
primary key,
"POPULATION TYPE" TEXT,
OCCURRENCES INTEGER,
"POPULATION COUNT" INTEGER,
"PREVALENCE RATE" REAL,
"PREVALENCE PERCENTAGE" REAL
);
CREATE TABLE patients
(
patient TEXT
primary key,
birthdate DATE,
deathdate DATE,
ssn TEXT,
drivers TEXT,
passport TEXT,
prefix TEXT,
first TEXT,
last TEXT,
suffix TEXT,
maiden TEXT,
marital TEXT,
race TEXT,
ethnicity TEXT,
gender TEXT,
birthplace TEXT,
address TEXT
);
CREATE TABLE encounters
(
ID TEXT
primary key,
DATE DATE,
PATIENT TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE allergies
(
START TEXT,
STOP TEXT,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE careplans
(
ID TEXT,
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE REAL,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE conditions
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient),
foreign key (DESCRIPTION) references all_prevalences(ITEM)
);
CREATE TABLE immunizations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (DATE, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE medications
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
primary key (START, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE observations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE TEXT,
DESCRIPTION TEXT,
VALUE REAL,
UNITS TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE procedures
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE IF NOT EXISTS "claims"
(
ID TEXT
primary key,
PATIENT TEXT
references patients,
BILLABLEPERIOD DATE,
ORGANIZATION TEXT,
ENCOUNTER TEXT
references encounters,
DIAGNOSIS TEXT,
TOTAL INTEGER
);
|
works_cycles | List all the names of products with the special offer "15". | SELECT T2.Name FROM SpecialOfferProduct AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SpecialOfferID = 15 | 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
);
|
|
public_review_platform | State the ID number for the attribute named "Accepts Insurance"? | ID number refers to attribute_id | SELECT attribute_id FROM Attributes WHERE attribute_name = 'Accepts Insurance' | 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
);
|
student_loan | List out the number of students who filed for bankruptcy and enlisted in navy. | navy refers to organ = 'navy'; | SELECT COUNT(T1.name) FROM enlist AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name WHERE T1.organ = 'navy' | CREATE TABLE bool
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE person
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE disabled
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE enlist
(
"name" TEXT not null,
organ TEXT not null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
"name" TEXT default '' not null
primary key,
"month" INTEGER default 0 null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE male
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
"name" TEXT default '' not null
primary key,
bool TEXT null,
foreign key ("name") references person ("name")
on update cascade on delete cascade,
foreign key (bool) references bool ("name")
on update cascade on delete cascade
);
CREATE TABLE unemployed
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
`name` TEXT NOT NULL,
`school` TEXT NOT NULL,
`month` INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (`name`,`school`),
FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
|
works_cycles | Please list the product names of all the products on the LL Road Frame Sale. | LL Road Frame Sale is a description of special offer | SELECT T3.Name FROM SpecialOffer AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN Product AS T3 ON T2.ProductID = T3.ProductID WHERE T1.Description = 'LL Road Frame Sale' | 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
);
|
hockey | Which is the catching hand for the goaltender who had the most shutouts in 1996? | the most shutouts refers to max(SHO); catching hand for the goaltender refers to shootCatch; shootCatch = 'L' refers to lefthand; shootCatch = 'R' refers to righthand; shootCatch = 'null' or 'empty' means this player is good at both left and right hand | SELECT T1.shootCatch FROM Master AS T1 INNER JOIN Goalies AS T2 ON T1.playerID = T2.playerID WHERE T2.year = 1996 ORDER BY T2.SHO 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)
);
|
law_episode | How many votes did the episode titled "Cherished" get in total? | titled "Cherished" refers to title = 'Cherished' | SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' | CREATE TABLE Episode
(
episode_id TEXT
primary key,
series TEXT,
season INTEGER,
episode INTEGER,
number_in_series INTEGER,
title TEXT,
summary TEXT,
air_date DATE,
episode_image TEXT,
rating REAL,
votes INTEGER
);
CREATE TABLE Keyword
(
episode_id TEXT,
keyword TEXT,
primary key (episode_id, keyword),
foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Person
(
person_id TEXT
primary key,
name TEXT,
birthdate DATE,
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,
series TEXT,
episode_id TEXT,
person_id TEXT,
role TEXT,
result TEXT,
foreign key (episode_id) references Episode(episode_id),
foreign key (person_id) references Person(person_id)
);
CREATE TABLE Credit
(
episode_id TEXT,
person_id TEXT,
category TEXT,
role TEXT,
credited TEXT,
primary key (episode_id, person_id),
foreign key (episode_id) references Episode(episode_id),
foreign key (person_id) references Person(person_id)
);
CREATE TABLE Vote
(
episode_id TEXT,
stars INTEGER,
votes INTEGER,
percent REAL,
foreign key (episode_id) references Episode(episode_id)
);
|
shipping | Determine the percentage of manufacturers who are from Texas among all of Lorenzo's customers. | "Texas" refers to state = 'TX'; 'manufacturer' is the cust_type; percentage = Divide (Count(cust_id where state = 'TX'), Count(cust_id)) * 100 | SELECT CAST(SUM(CASE WHEN cust_type = 'manufacturer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM customer WHERE state = 'TX' | CREATE TABLE city
(
city_id INTEGER
primary key,
city_name TEXT,
state TEXT,
population INTEGER,
area REAL
);
CREATE TABLE customer
(
cust_id INTEGER
primary key,
cust_name TEXT,
annual_revenue INTEGER,
cust_type TEXT,
address TEXT,
city TEXT,
state TEXT,
zip REAL,
phone TEXT
);
CREATE TABLE driver
(
driver_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip_code INTEGER,
phone TEXT
);
CREATE TABLE truck
(
truck_id INTEGER
primary key,
make TEXT,
model_year INTEGER
);
CREATE TABLE shipment
(
ship_id INTEGER
primary key,
cust_id INTEGER,
weight REAL,
truck_id INTEGER,
driver_id INTEGER,
city_id INTEGER,
ship_date TEXT,
foreign key (cust_id) references customer(cust_id),
foreign key (city_id) references city(city_id),
foreign key (driver_id) references driver(driver_id),
foreign key (truck_id) references truck(truck_id)
);
|
cs_semester | Who were the students who failed the course "Applied Deep Learning"? Give the full name. | If grade is null or empty, it means that this student fails to pass the course in which grade = NULL; | SELECT T1.f_name, T1.l_name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Applied Deep Learning ' AND T2.grade IS NULL | CREATE TABLE IF NOT EXISTS "course"
(
course_id INTEGER
constraint course_pk
primary key,
name TEXT,
credit INTEGER,
diff INTEGER
);
CREATE TABLE prof
(
prof_id INTEGER
constraint prof_pk
primary key,
gender TEXT,
first_name TEXT,
last_name TEXT,
email TEXT,
popularity INTEGER,
teachingability INTEGER,
graduate_from TEXT
);
CREATE TABLE RA
(
student_id INTEGER,
capability INTEGER,
prof_id INTEGER,
salary TEXT,
primary key (student_id, prof_id),
foreign key (prof_id) references prof(prof_id),
foreign key (student_id) references student(student_id)
);
CREATE TABLE registration
(
course_id INTEGER,
student_id INTEGER,
grade TEXT,
sat INTEGER,
primary key (course_id, student_id),
foreign key (course_id) references course(course_id),
foreign key (student_id) references student(student_id)
);
CREATE TABLE student
(
student_id INTEGER
primary key,
f_name TEXT,
l_name TEXT,
phone_number TEXT,
email TEXT,
intelligence INTEGER,
gpa REAL,
type TEXT
);
|
software_company | Among the male customers, how many of them come from a place with over 30,000 inhabitants? | SEX = 'Male', over 30,000 inhabitants refer to NHABITANTS_K > 30; place refers to GEOID; | SELECT COUNT(T1.GEOID) FROM Customers AS T1 INNER JOIN Demog AS T2 ON T1.GEOID = T2.GEOID WHERE T1.SEX = 'Male' AND T2.INHABITANTS_K > 30 | CREATE TABLE Demog
(
GEOID INTEGER
constraint Demog_pk
primary key,
INHABITANTS_K REAL,
INCOME_K REAL,
A_VAR1 REAL,
A_VAR2 REAL,
A_VAR3 REAL,
A_VAR4 REAL,
A_VAR5 REAL,
A_VAR6 REAL,
A_VAR7 REAL,
A_VAR8 REAL,
A_VAR9 REAL,
A_VAR10 REAL,
A_VAR11 REAL,
A_VAR12 REAL,
A_VAR13 REAL,
A_VAR14 REAL,
A_VAR15 REAL,
A_VAR16 REAL,
A_VAR17 REAL,
A_VAR18 REAL
);
CREATE TABLE mailings3
(
REFID INTEGER
constraint mailings3_pk
primary key,
REF_DATE DATETIME,
RESPONSE TEXT
);
CREATE TABLE IF NOT EXISTS "Customers"
(
ID INTEGER
constraint Customers_pk
primary key,
SEX TEXT,
MARITAL_STATUS TEXT,
GEOID INTEGER
constraint Customers_Demog_GEOID_fk
references Demog,
EDUCATIONNUM INTEGER,
OCCUPATION TEXT,
age INTEGER
);
CREATE TABLE IF NOT EXISTS "Mailings1_2"
(
REFID INTEGER
constraint Mailings1_2_pk
primary key
constraint Mailings1_2_Customers_ID_fk
references Customers,
REF_DATE DATETIME,
RESPONSE TEXT
);
CREATE TABLE IF NOT EXISTS "Sales"
(
EVENTID INTEGER
constraint Sales_pk
primary key,
REFID INTEGER
references Customers,
EVENT_DATE DATETIME,
AMOUNT REAL
);
|
movies_4 | Among Warner Bros. Pictures' movies, which title made the highest revenue? | Warner Bros. Pictures' movies refers to company_name = 'Warner Bros. Pictures'; highest revenue refers to max(revenue) | SELECT T3.title FROM production_company AS T1 INNER JOIN movie_company AS T2 ON T1.company_id = T2.company_id INNER JOIN movie AS T3 ON T2.movie_id = T3.movie_id WHERE T1.company_name = 'Warner Bros. Pictures' ORDER BY T3.revenue DESC LIMIT 1 | CREATE TABLE country
(
country_id INTEGER not null
primary key,
country_iso_code TEXT default NULL,
country_name TEXT default NULL
);
CREATE TABLE department
(
department_id INTEGER not null
primary key,
department_name TEXT default NULL
);
CREATE TABLE gender
(
gender_id INTEGER not null
primary key,
gender TEXT default NULL
);
CREATE TABLE genre
(
genre_id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE keyword
(
keyword_id INTEGER not null
primary key,
keyword_name TEXT default NULL
);
CREATE TABLE language
(
language_id INTEGER not null
primary key,
language_code TEXT default NULL,
language_name TEXT default NULL
);
CREATE TABLE language_role
(
role_id INTEGER not null
primary key,
language_role TEXT default NULL
);
CREATE TABLE movie
(
movie_id INTEGER not null
primary key,
title TEXT default NULL,
budget INTEGER default NULL,
homepage TEXT default NULL,
overview TEXT default NULL,
popularity REAL default NULL,
release_date DATE default NULL,
revenue INTEGER default NULL,
runtime INTEGER default NULL,
movie_status TEXT default NULL,
tagline TEXT default NULL,
vote_average REAL default NULL,
vote_count INTEGER default NULL
);
CREATE TABLE movie_genres
(
movie_id INTEGER default NULL,
genre_id INTEGER default NULL,
foreign key (genre_id) references genre(genre_id),
foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_languages
(
movie_id INTEGER default NULL,
language_id INTEGER default NULL,
language_role_id INTEGER default NULL,
foreign key (language_id) references language(language_id),
foreign key (movie_id) references movie(movie_id),
foreign key (language_role_id) references language_role(role_id)
);
CREATE TABLE person
(
person_id INTEGER not null
primary key,
person_name TEXT default NULL
);
CREATE TABLE movie_crew
(
movie_id INTEGER default NULL,
person_id INTEGER default NULL,
department_id INTEGER default NULL,
job TEXT default NULL,
foreign key (department_id) references department(department_id),
foreign key (movie_id) references movie(movie_id),
foreign key (person_id) references person(person_id)
);
CREATE TABLE production_company
(
company_id INTEGER not null
primary key,
company_name TEXT default NULL
);
CREATE TABLE production_country
(
movie_id INTEGER default NULL,
country_id INTEGER default NULL,
foreign key (country_id) references country(country_id),
foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_cast
(
movie_id INTEGER default NULL,
person_id INTEGER default NULL,
character_name TEXT default NULL,
gender_id INTEGER default NULL,
cast_order INTEGER default NULL,
foreign key (gender_id) references gender(gender_id),
foreign key (movie_id) references movie(movie_id),
foreign key (person_id) references person(person_id)
);
CREATE TABLE IF NOT EXISTS "movie_keywords"
(
movie_id INTEGER default NULL
references movie,
keyword_id INTEGER default NULL
references keyword
);
CREATE TABLE IF NOT EXISTS "movie_company"
(
movie_id INTEGER default NULL
references movie,
company_id INTEGER default NULL
references production_company
);
|
world_development_indicators | List all the country in East Asia & Pacific region that have more than 2000000 urban population in 1970. | country refers to LongName; have more than 2000000 urban population refers to value where indicatorname = 'Urban population'>2000000; in 1970 refers to year = '1970' | SELECT DISTINCT T1.CountryCode FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T2.Year = 1970 AND T1.Region = 'East Asia & Pacific' AND T2.Value > 2000000 AND t2.indicatorname = 'Urban population' | CREATE TABLE IF NOT EXISTS "Country"
(
CountryCode TEXT not null
primary key,
ShortName TEXT,
TableName TEXT,
LongName TEXT,
Alpha2Code TEXT,
CurrencyUnit TEXT,
SpecialNotes TEXT,
Region TEXT,
IncomeGroup TEXT,
Wb2Code TEXT,
NationalAccountsBaseYear TEXT,
NationalAccountsReferenceYear TEXT,
SnaPriceValuation TEXT,
LendingCategory TEXT,
OtherGroups TEXT,
SystemOfNationalAccounts TEXT,
AlternativeConversionFactor TEXT,
PppSurveyYear TEXT,
BalanceOfPaymentsManualInUse TEXT,
ExternalDebtReportingStatus TEXT,
SystemOfTrade TEXT,
GovernmentAccountingConcept TEXT,
ImfDataDisseminationStandard TEXT,
LatestPopulationCensus TEXT,
LatestHouseholdSurvey TEXT,
SourceOfMostRecentIncomeAndExpenditureData TEXT,
VitalRegistrationComplete TEXT,
LatestAgriculturalCensus TEXT,
LatestIndustrialData INTEGER,
LatestTradeData INTEGER,
LatestWaterWithdrawalData INTEGER
);
CREATE TABLE IF NOT EXISTS "Series"
(
SeriesCode TEXT not null
primary key,
Topic TEXT,
IndicatorName TEXT,
ShortDefinition TEXT,
LongDefinition TEXT,
UnitOfMeasure TEXT,
Periodicity TEXT,
BasePeriod TEXT,
OtherNotes INTEGER,
AggregationMethod TEXT,
LimitationsAndExceptions TEXT,
NotesFromOriginalSource TEXT,
GeneralComments TEXT,
Source TEXT,
StatisticalConceptAndMethodology TEXT,
DevelopmentRelevance TEXT,
RelatedSourceLinks TEXT,
OtherWebLinks INTEGER,
RelatedIndicators INTEGER,
LicenseType TEXT
);
CREATE TABLE CountryNotes
(
Countrycode TEXT NOT NULL ,
Seriescode TEXT NOT NULL ,
Description TEXT,
primary key (Countrycode, Seriescode),
FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Footnotes
(
Countrycode TEXT NOT NULL ,
Seriescode TEXT NOT NULL ,
Year TEXT,
Description TEXT,
primary key (Countrycode, Seriescode, Year),
FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Indicators
(
CountryName TEXT,
CountryCode TEXT NOT NULL ,
IndicatorName TEXT,
IndicatorCode TEXT NOT NULL ,
Year INTEGER NOT NULL ,
Value INTEGER,
primary key (CountryCode, IndicatorCode, Year),
FOREIGN KEY (CountryCode) REFERENCES Country(CountryCode)
);
CREATE TABLE SeriesNotes
(
Seriescode TEXT not null ,
Year TEXT not null ,
Description TEXT,
primary key (Seriescode, Year),
foreign key (Seriescode) references Series(SeriesCode)
);
|
movie_platform | What's of rating on the movie "Innocence Unprotected" by the user who created the movie list "250 Favourite Films"? | Innocence Unprotected' is movie_title; '250 Favourite Films' is list_title; rating refers to rating_score; | SELECT T1.rating_score FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id INNER JOIN lists AS T3 ON T3.user_id = T1.user_id WHERE T2.movie_title = 'Innocence Unprotected' AND T3.list_title = '250 Favourite Films' | CREATE TABLE IF NOT EXISTS "lists"
(
user_id INTEGER
references lists_users (user_id),
list_id INTEGER not null
primary key,
list_title TEXT,
list_movie_number INTEGER,
list_update_timestamp_utc TEXT,
list_creation_timestamp_utc TEXT,
list_followers INTEGER,
list_url TEXT,
list_comments INTEGER,
list_description TEXT,
list_cover_image_url TEXT,
list_first_image_url TEXT,
list_second_image_url TEXT,
list_third_image_url TEXT
);
CREATE TABLE IF NOT EXISTS "movies"
(
movie_id INTEGER not null
primary key,
movie_title TEXT,
movie_release_year INTEGER,
movie_url TEXT,
movie_title_language TEXT,
movie_popularity INTEGER,
movie_image_url TEXT,
director_id TEXT,
director_name TEXT,
director_url TEXT
);
CREATE TABLE IF NOT EXISTS "ratings_users"
(
user_id INTEGER
references lists_users (user_id),
rating_date_utc TEXT,
user_trialist INTEGER,
user_subscriber INTEGER,
user_avatar_image_url TEXT,
user_cover_image_url TEXT,
user_eligible_for_trial INTEGER,
user_has_payment_method INTEGER
);
CREATE TABLE lists_users
(
user_id INTEGER not null ,
list_id INTEGER not null ,
list_update_date_utc TEXT,
list_creation_date_utc TEXT,
user_trialist INTEGER,
user_subscriber INTEGER,
user_avatar_image_url TEXT,
user_cover_image_url TEXT,
user_eligible_for_trial TEXT,
user_has_payment_method TEXT,
primary key (user_id, list_id),
foreign key (list_id) references lists(list_id),
foreign key (user_id) references lists(user_id)
);
CREATE TABLE ratings
(
movie_id INTEGER,
rating_id INTEGER,
rating_url TEXT,
rating_score INTEGER,
rating_timestamp_utc TEXT,
critic TEXT,
critic_likes INTEGER,
critic_comments INTEGER,
user_id INTEGER,
user_trialist INTEGER,
user_subscriber INTEGER,
user_eligible_for_trial INTEGER,
user_has_payment_method INTEGER,
foreign key (movie_id) references movies(movie_id),
foreign key (user_id) references lists_users(user_id),
foreign key (rating_id) references ratings(rating_id),
foreign key (user_id) references ratings_users(user_id)
);
|
shipping | Among the customers having at least one shipment in 2017, how many of them have an annual revenue of over 30000000? | shipment in 2017 refers to Cast(ship_date AS DATE) = 2017; annual revenue of over 30000000 refers to annual_revenue > 30000000 | SELECT COUNT(COUNTCUSID) FROM ( SELECT COUNT(T1.cust_id) AS COUNTCUSID FROM customer AS T1 INNER JOIN shipment AS T2 ON T1.cust_id = T2.cust_id WHERE STRFTIME('%Y', T2.ship_date) = '2017' AND T1.annual_revenue > 30000000 GROUP BY T1.cust_id HAVING COUNT(T2.ship_id) >= 1 ) T3 | CREATE TABLE city
(
city_id INTEGER
primary key,
city_name TEXT,
state TEXT,
population INTEGER,
area REAL
);
CREATE TABLE customer
(
cust_id INTEGER
primary key,
cust_name TEXT,
annual_revenue INTEGER,
cust_type TEXT,
address TEXT,
city TEXT,
state TEXT,
zip REAL,
phone TEXT
);
CREATE TABLE driver
(
driver_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip_code INTEGER,
phone TEXT
);
CREATE TABLE truck
(
truck_id INTEGER
primary key,
make TEXT,
model_year INTEGER
);
CREATE TABLE shipment
(
ship_id INTEGER
primary key,
cust_id INTEGER,
weight REAL,
truck_id INTEGER,
driver_id INTEGER,
city_id INTEGER,
ship_date TEXT,
foreign key (cust_id) references customer(cust_id),
foreign key (city_id) references city(city_id),
foreign key (driver_id) references driver(driver_id),
foreign key (truck_id) references truck(truck_id)
);
|
shipping | State the address of drivers who transported the shipment with weight greater than 50000 pounds. | shipment with weight greater than 50000 pounds refers to Sum(weight) > 50000 | SELECT T2.address FROM shipment AS T1 INNER JOIN driver AS T2 ON T1.driver_id = T2.driver_id GROUP BY T2.driver_id HAVING SUM(T1.weight) > 50000 | CREATE TABLE city
(
city_id INTEGER
primary key,
city_name TEXT,
state TEXT,
population INTEGER,
area REAL
);
CREATE TABLE customer
(
cust_id INTEGER
primary key,
cust_name TEXT,
annual_revenue INTEGER,
cust_type TEXT,
address TEXT,
city TEXT,
state TEXT,
zip REAL,
phone TEXT
);
CREATE TABLE driver
(
driver_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip_code INTEGER,
phone TEXT
);
CREATE TABLE truck
(
truck_id INTEGER
primary key,
make TEXT,
model_year INTEGER
);
CREATE TABLE shipment
(
ship_id INTEGER
primary key,
cust_id INTEGER,
weight REAL,
truck_id INTEGER,
driver_id INTEGER,
city_id INTEGER,
ship_date TEXT,
foreign key (cust_id) references customer(cust_id),
foreign key (city_id) references city(city_id),
foreign key (driver_id) references driver(driver_id),
foreign key (truck_id) references truck(truck_id)
);
|
world | Among the countries that use Italian as their language, what is the percentage of republic countries? | use Italian as their language refers to `Language` = 'Italian'; percentage = MULTIPLY(DIVIDE(SUM(`Language` = 'Italian' WHERE GovernmentForm = 'Republic'), COUNT(`Language` = 'Italian')), 100); use Italian as their language refers to `Language` = 'Italian'; republic countries refers to GovernmentForm = 'Republic'; | SELECT CAST(SUM(CASE WHEN T2.GovernmentForm = 'Republic' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Language = 'Italian' | CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE `City` (
`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`Name` TEXT NOT NULL DEFAULT '',
`CountryCode` TEXT NOT NULL DEFAULT '',
`District` TEXT NOT NULL DEFAULT '',
`Population` INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
);
CREATE TABLE `Country` (
`Code` TEXT NOT NULL DEFAULT '',
`Name` TEXT NOT NULL DEFAULT '',
`Continent` TEXT NOT NULL DEFAULT 'Asia',
`Region` TEXT NOT NULL DEFAULT '',
`SurfaceArea` REAL NOT NULL DEFAULT 0.00,
`IndepYear` INTEGER DEFAULT NULL,
`Population` INTEGER NOT NULL DEFAULT 0,
`LifeExpectancy` REAL DEFAULT NULL,
`GNP` REAL DEFAULT NULL,
`GNPOld` REAL DEFAULT NULL,
`LocalName` TEXT NOT NULL DEFAULT '',
`GovernmentForm` TEXT NOT NULL DEFAULT '',
`HeadOfState` TEXT DEFAULT NULL,
`Capital` INTEGER DEFAULT NULL,
`Code2` TEXT NOT NULL DEFAULT '',
PRIMARY KEY (`Code`)
);
CREATE TABLE `CountryLanguage` (
`CountryCode` TEXT NOT NULL DEFAULT '',
`Language` TEXT NOT NULL DEFAULT '',
`IsOfficial`TEXT NOT NULL DEFAULT 'F',
`Percentage` REAL NOT NULL DEFAULT 0.0,
PRIMARY KEY (`CountryCode`,`Language`),
FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
);
|
mondial_geo | For the country in which Olsztyn is located, where is the capital? | Olsztyn is one of country names | SELECT T1.Capital FROM country AS T1 INNER JOIN city AS T2 ON T1.Code = T2.Country WHERE T2.Name = 'Olsztyn' | 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
);
|
chicago_crime | Give the name of the community area which had the most pocket-picking thefts. | name of the community area refers to community_area_name; the most refers to max(case_number); pocket-picking theft refers to primary_description = 'THEFT' AND secondary_description = 'POCKET-PICKING' | SELECT T3.community_area_name FROM IUCR AS T1 INNER JOIN Crime AS T2 ON T1.iucr_no = T2.iucr_no INNER JOIN Community_Area AS T3 ON T2.community_area_no = T3.community_area_no WHERE T1.primary_description = 'THEFT' AND T1.secondary_description = 'POCKET-PICKING' GROUP BY T2.community_area_no ORDER BY T2.case_number DESC LIMIT 1 | 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)
);
|
food_inspection_2 | How much did Hacienda Los Torres from ward 36 fine for failing an inspection? | Hacienda Los Torres refers to dba_name = 'HACIENDA LOS TORRES'; ward 36 refers to ward = 36; failing an inspection refers to results = 'Fail'; | SELECT SUM(T3.fine) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN violation AS T3 ON T2.inspection_id = T3.inspection_id WHERE T1.dba_name = 'HACIENDA LOS TORRES' AND T1.ward = 36 AND T2.results = 'Fail' | CREATE TABLE employee
(
employee_id INTEGER
primary key,
first_name TEXT,
last_name TEXT,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
phone TEXT,
title TEXT,
salary INTEGER,
supervisor INTEGER,
foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
license_no INTEGER
primary key,
dba_name TEXT,
aka_name TEXT,
facility_type TEXT,
risk_level INTEGER,
address TEXT,
city TEXT,
state TEXT,
zip INTEGER,
latitude REAL,
longitude REAL,
ward INTEGER
);
CREATE TABLE inspection
(
inspection_id INTEGER
primary key,
inspection_date DATE,
inspection_type TEXT,
results TEXT,
employee_id INTEGER,
license_no INTEGER,
followup_to INTEGER,
foreign key (employee_id) references employee(employee_id),
foreign key (license_no) references establishment(license_no),
foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
point_id INTEGER
primary key,
Description TEXT,
category TEXT,
code TEXT,
fine INTEGER,
point_level TEXT
);
CREATE TABLE violation
(
inspection_id INTEGER,
point_id INTEGER,
fine INTEGER,
inspector_comment TEXT,
primary key (inspection_id, point_id),
foreign key (inspection_id) references inspection(inspection_id),
foreign key (point_id) references inspection_point(point_id)
);
|
cs_semester | What is the average gpa of Ogdon Zywicki's research assistants? | research assistant refers to the student who serves for research where the abbreviation is RA; prof_id refers to professor’s ID; GPA is an abbreviated name of Grade Point Average where average = AVG(gpa); | SELECT SUM(T3.gpa) / COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T1.student_id = T3.student_id WHERE T2.first_name = 'Ogdon' AND T2.last_name = 'Zywicki' | CREATE TABLE IF NOT EXISTS "course"
(
course_id INTEGER
constraint course_pk
primary key,
name TEXT,
credit INTEGER,
diff INTEGER
);
CREATE TABLE prof
(
prof_id INTEGER
constraint prof_pk
primary key,
gender TEXT,
first_name TEXT,
last_name TEXT,
email TEXT,
popularity INTEGER,
teachingability INTEGER,
graduate_from TEXT
);
CREATE TABLE RA
(
student_id INTEGER,
capability INTEGER,
prof_id INTEGER,
salary TEXT,
primary key (student_id, prof_id),
foreign key (prof_id) references prof(prof_id),
foreign key (student_id) references student(student_id)
);
CREATE TABLE registration
(
course_id INTEGER,
student_id INTEGER,
grade TEXT,
sat INTEGER,
primary key (course_id, student_id),
foreign key (course_id) references course(course_id),
foreign key (student_id) references student(student_id)
);
CREATE TABLE student
(
student_id INTEGER
primary key,
f_name TEXT,
l_name TEXT,
phone_number TEXT,
email TEXT,
intelligence INTEGER,
gpa REAL,
type TEXT
);
|
student_loan | How many students have absences of no more than 3 months? | absences of no more than 3 months refers to month < 3; | SELECT COUNT(name) FROM longest_absense_from_school WHERE month < 3 | CREATE TABLE bool
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE person
(
"name" TEXT default '' not null
primary key
);
CREATE TABLE disabled
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE enlist
(
"name" TEXT not null,
organ TEXT not null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
"name" TEXT default '' not null
primary key,
"month" INTEGER default 0 null,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE male
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
"name" TEXT default '' not null
primary key,
bool TEXT null,
foreign key ("name") references person ("name")
on update cascade on delete cascade,
foreign key (bool) references bool ("name")
on update cascade on delete cascade
);
CREATE TABLE unemployed
(
"name" TEXT default '' not null
primary key,
foreign key ("name") references person ("name")
on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
`name` TEXT NOT NULL,
`school` TEXT NOT NULL,
`month` INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (`name`,`school`),
FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
|
computer_student | Which level of courses is taught by professor ID 297? | professor ID 297 refers to taughtBy.p_id = 297 | SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 297 | CREATE TABLE course
(
course_id INTEGER
constraint course_pk
primary key,
courseLevel TEXT
);
CREATE TABLE person
(
p_id INTEGER
constraint person_pk
primary key,
professor INTEGER,
student INTEGER,
hasPosition TEXT,
inPhase TEXT,
yearsInProgram TEXT
);
CREATE TABLE IF NOT EXISTS "advisedBy"
(
p_id INTEGER,
p_id_dummy INTEGER,
constraint advisedBy_pk
primary key (p_id, p_id_dummy),
constraint advisedBy_person_p_id_p_id_fk
foreign key (p_id, p_id_dummy) references person (p_id, p_id)
);
CREATE TABLE taughtBy
(
course_id INTEGER,
p_id INTEGER,
primary key (course_id, p_id),
foreign key (p_id) references person(p_id),
foreign key (course_id) references course(course_id)
);
|
synthea | For how many times had Elly Koss have her Systolic Blood Pressure observed? | Systolic Blood Pressure refers to DESCRIPTION = 'Systolic Blood Pressure'; | SELECT COUNT(T2.description) FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure' | CREATE TABLE all_prevalences
(
ITEM TEXT
primary key,
"POPULATION TYPE" TEXT,
OCCURRENCES INTEGER,
"POPULATION COUNT" INTEGER,
"PREVALENCE RATE" REAL,
"PREVALENCE PERCENTAGE" REAL
);
CREATE TABLE patients
(
patient TEXT
primary key,
birthdate DATE,
deathdate DATE,
ssn TEXT,
drivers TEXT,
passport TEXT,
prefix TEXT,
first TEXT,
last TEXT,
suffix TEXT,
maiden TEXT,
marital TEXT,
race TEXT,
ethnicity TEXT,
gender TEXT,
birthplace TEXT,
address TEXT
);
CREATE TABLE encounters
(
ID TEXT
primary key,
DATE DATE,
PATIENT TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE allergies
(
START TEXT,
STOP TEXT,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE careplans
(
ID TEXT,
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE REAL,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE conditions
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient),
foreign key (DESCRIPTION) references all_prevalences(ITEM)
);
CREATE TABLE immunizations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
primary key (DATE, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE medications
(
START DATE,
STOP DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
primary key (START, PATIENT, ENCOUNTER, CODE),
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE observations
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE TEXT,
DESCRIPTION TEXT,
VALUE REAL,
UNITS TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE procedures
(
DATE DATE,
PATIENT TEXT,
ENCOUNTER TEXT,
CODE INTEGER,
DESCRIPTION TEXT,
REASONCODE INTEGER,
REASONDESCRIPTION TEXT,
foreign key (ENCOUNTER) references encounters(ID),
foreign key (PATIENT) references patients(patient)
);
CREATE TABLE IF NOT EXISTS "claims"
(
ID TEXT
primary key,
PATIENT TEXT
references patients,
BILLABLEPERIOD DATE,
ORGANIZATION TEXT,
ENCOUNTER TEXT
references encounters,
DIAGNOSIS TEXT,
TOTAL INTEGER
);
|
car_retails | Among the motorcycles with product scale of 1:10, which of them is the most ordered by American customers? | motorcycle is a product line; American is a nationality of country = 'USA'; | SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T1.productLine = 'Motorcycles' AND T1.productScale = '1:10' AND T4.country = 'USA' 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)
);
|
language_corpus | How many Wikipedia pages with over 4000 different words are there on the Catalan language? | lid = 1 means it's Catalan language; over 4000 different words means words > 4000; Wikipedia pages refers to pid | SELECT COUNT(lid) FROM pages WHERE lid = 1 AND words > 4000 | 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;
|
human_resources | How many Account Representatives are there in Illinois with satisfying performance? | Account Representatives is a position title; satisfying performance mostly refers togood performance | SELECT COUNT(*) FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID INNER JOIN position AS T3 ON T3.positionID = T1.positionID WHERE T3.positiontitle = 'Account Representative' AND T1.performance = 'Good' AND T2.state = 'IL' | CREATE TABLE location
(
locationID INTEGER
constraint location_pk
primary key,
locationcity TEXT,
address TEXT,
state TEXT,
zipcode INTEGER,
officephone TEXT
);
CREATE TABLE position
(
positionID INTEGER
constraint position_pk
primary key,
positiontitle TEXT,
educationrequired TEXT,
minsalary TEXT,
maxsalary TEXT
);
CREATE TABLE employee
(
ssn TEXT
primary key,
lastname TEXT,
firstname TEXT,
hiredate TEXT,
salary TEXT,
gender TEXT,
performance TEXT,
positionID INTEGER,
locationID INTEGER,
foreign key (locationID) references location(locationID),
foreign key (positionID) references position(positionID)
);
|
public_review_platform | Please provide the attribute values of the bussinesses with fashion in Scottsdale. | fashion refers to category_name = 'Fashion'; Scottsdale refers to city = 'Scottsdale'; | SELECT T2.attribute_value FROM Business AS T1 INNER JOIN Business_Attributes AS T2 ON T1.business_id = T2.business_id INNER JOIN Business_Categories AS T3 ON T1.business_id = T3.business_id INNER JOIN Categories AS T4 ON T3.category_id = T4.category_id WHERE T4.category_name LIKE 'Fashion' AND T1.city LIKE 'Scottsdale' | 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 | How many customers with a canceled shipment have a credit limit greater than 115,000? | cancelled shipment refers to status = 'cancelled'; creditLimit > 115000; | SELECT COUNT(T1.customerNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.status = 'Cancelled' AND T1.creditLimit > 115000 | 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)
);
|
video_games | What is the average number of games published by a publisher? | average number = divide(count(game_id), count(publisher_id)) | SELECT CAST(COUNT(T.game_id) AS REAL) / COUNT(DISTINCT T.publisher_id) FROM game_publisher AS T | CREATE TABLE genre
(
id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE game
(
id INTEGER not null
primary key,
genre_id INTEGER default NULL,
game_name TEXT default NULL,
foreign key (genre_id) references genre(id)
);
CREATE TABLE platform
(
id INTEGER not null
primary key,
platform_name TEXT default NULL
);
CREATE TABLE publisher
(
id INTEGER not null
primary key,
publisher_name TEXT default NULL
);
CREATE TABLE game_publisher
(
id INTEGER not null
primary key,
game_id INTEGER default NULL,
publisher_id INTEGER default NULL,
foreign key (game_id) references game(id),
foreign key (publisher_id) references publisher(id)
);
CREATE TABLE game_platform
(
id INTEGER not null
primary key,
game_publisher_id INTEGER default NULL,
platform_id INTEGER default NULL,
release_year INTEGER default NULL,
foreign key (game_publisher_id) references game_publisher(id),
foreign key (platform_id) references platform(id)
);
CREATE TABLE region
(
id INTEGER not null
primary key,
region_name TEXT default NULL
);
CREATE TABLE region_sales
(
region_id INTEGER default NULL,
game_platform_id INTEGER default NULL,
num_sales REAL default NULL,
foreign key (game_platform_id) references game_platform(id),
foreign key (region_id) references region(id)
);
|
disney | Provide the director's name of Wreck-It Ralph movie. | Wreck-It Ralph is the name of the movies which refers to name = 'Wreck-It Ralph'; | SELECT director FROM director WHERE name = 'Wreck-It Ralph' | CREATE TABLE characters
(
movie_title TEXT
primary key,
release_date TEXT,
hero TEXT,
villian TEXT,
song TEXT,
foreign key (hero) references "voice-actors"(character)
);
CREATE TABLE director
(
name TEXT
primary key,
director TEXT,
foreign key (name) references characters(movie_title)
);
CREATE TABLE movies_total_gross
(
movie_title TEXT,
release_date TEXT,
genre TEXT,
MPAA_rating TEXT,
total_gross TEXT,
inflation_adjusted_gross TEXT,
primary key (movie_title, release_date),
foreign key (movie_title) references characters(movie_title)
);
CREATE TABLE revenue
(
Year INTEGER
primary key,
"Studio Entertainment[NI 1]" REAL,
"Disney Consumer Products[NI 2]" REAL,
"Disney Interactive[NI 3][Rev 1]" INTEGER,
"Walt Disney Parks and Resorts" REAL,
"Disney Media Networks" TEXT,
Total INTEGER
);
CREATE TABLE IF NOT EXISTS "voice-actors"
(
character TEXT
primary key,
"voice-actor" TEXT,
movie TEXT,
foreign key (movie) references characters(movie_title)
);
|
hockey | Please list the awards won by coaches who were born in 1952. | born in 1977 refers to birthYear = '1977' | SELECT T2.award FROM Master AS T1 INNER JOIN AwardsCoaches AS T2 ON T1.coachID = T2.coachID WHERE T1.birthYear = 1952 | 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)
);
|
genes | How many pairs of positively correlated genes are both non-essential? | If Expression_Corr > 0, it means the expression correlation is positive | SELECT COUNT(T2.GeneID2) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Expression_Corr > 0 AND T1.Essential = 'Non-Essential' | CREATE TABLE Classification
(
GeneID TEXT not null
primary key,
Localization TEXT not null
);
CREATE TABLE Genes
(
GeneID TEXT not null,
Essential TEXT not null,
Class TEXT not null,
Complex TEXT null,
Phenotype TEXT not null,
Motif TEXT not null,
Chromosome INTEGER not null,
Function TEXT not null,
Localization TEXT not null,
foreign key (GeneID) references Classification (GeneID)
on update cascade on delete cascade
);
CREATE TABLE Interactions
(
GeneID1 TEXT not null,
GeneID2 TEXT not null,
Type TEXT not null,
Expression_Corr REAL not null,
primary key (GeneID1, GeneID2),
foreign key (GeneID1) references Classification (GeneID)
on update cascade on delete cascade,
foreign key (GeneID2) references Classification (GeneID)
on update cascade on delete cascade
);
|
mondial_geo | Name all the volcano mountains between the height of 2000 to 4000. | SELECT Name FROM mountain WHERE Type = 'volcano' AND Height BETWEEN 2000 AND 4000 | 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
);
|
|
car_retails | Please calculate the average total price of shipped orders from German customers. | average total price = DIVIDE(MULTIPLY(quantityOrdered, priceEach)), COUNT(orderNumber)); German is a nationality of country = 'Germany'; shipped orders refers to status = 'Shipped'; | SELECT SUM(T3.quantityOrdered * T3.priceEach) / COUNT(T2.orderNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN orderdetails AS T3 ON T2.orderNumber = T3.orderNumber WHERE T2.status = 'Shipped' AND T1.country = 'Germany' | 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)
);
|
chicago_crime | How many crimes happened in longitude -8772658001? | SELECT COUNT(*) FROM Crime WHERE longitude = '-87.72658001' | 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 of the businesses are in Surprise? | Surprise is a city | SELECT COUNT(business_id) FROM Business WHERE city = 'Surprise' | 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
);
|
retail_world | List the products whose supplier is Pavlova, Ltd. Please include the product ID and re-order level. | "Pavlova, Ltd" is the CompanyName; products refers to ProductName | SELECT T1.ProductName, T1.ProductID, T1.ReorderLevel FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Pavlova, Ltd.' | 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)
);
|
airline | What is the name of the airline that flew the most flights to Chicago Midway International? | name of the airline refers to Description; flights to refers to DEST; Chicago Midway International refers to Description = 'Chicago, IL: Chicago Midway International'; most flights to Chicago Midway International refers to MAX(COUNT(DEST WHERE Description = 'Chicago, IL: Chicago Midway International')); | SELECT T3.Description FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST INNER JOIN `Air Carriers` AS T3 ON T2.OP_CARRIER_AIRLINE_ID = T3.Code WHERE T1.Description = 'Chicago, IL: Chicago Midway International' AND T2.DEST = 'MDW' GROUP BY T3.Description ORDER BY COUNT(T3.Description) DESC LIMIT 1 | 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)
);
|
works_cycles | How much is HL Grip Tape's profit ratio? | HL Grip Tape refers to the product name; DIVIDE(SUBTRACT(LastReceiptCost, StandardPrice)), (StandardPrice) as profit_ratio | SELECT (T1.LastReceiptCost - T1.StandardPrice) / T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'HL Grip Tape' | 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
);
|
image_and_language | What colour is the van that can be spotted in image no. 1? | colour refers to ATT_CLASS; van refers to OBJ_CLASS = 'van'; image no. 1 refers to IMG_ID = 1 | SELECT T4.ATT_CLASS FROM IMG_OBJ AS T1 INNER JOIN OBJ_CLASSES AS T2 ON T1.OBJ_CLASS_ID = T2.OBJ_CLASS_ID INNER JOIN IMG_OBJ_ATT AS T3 ON T1.IMG_ID = T3.IMG_ID INNER JOIN ATT_CLASSES AS T4 ON T3.ATT_CLASS_ID = T4.ATT_CLASS_ID WHERE T2.OBJ_CLASS = 'van' AND T1.IMG_ID = 1 GROUP BY T4.ATT_CLASS | CREATE TABLE ATT_CLASSES
(
ATT_CLASS_ID INTEGER default 0 not null
primary key,
ATT_CLASS TEXT not null
);
CREATE TABLE OBJ_CLASSES
(
OBJ_CLASS_ID INTEGER default 0 not null
primary key,
OBJ_CLASS TEXT not null
);
CREATE TABLE IMG_OBJ
(
IMG_ID INTEGER default 0 not null,
OBJ_SAMPLE_ID INTEGER default 0 not null,
OBJ_CLASS_ID INTEGER null,
X INTEGER null,
Y INTEGER null,
W INTEGER null,
H INTEGER null,
primary key (IMG_ID, OBJ_SAMPLE_ID),
foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID)
);
CREATE TABLE IMG_OBJ_ATT
(
IMG_ID INTEGER default 0 not null,
ATT_CLASS_ID INTEGER default 0 not null,
OBJ_SAMPLE_ID INTEGER default 0 not null,
primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID),
foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID),
foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
CREATE TABLE PRED_CLASSES
(
PRED_CLASS_ID INTEGER default 0 not null
primary key,
PRED_CLASS TEXT not null
);
CREATE TABLE IMG_REL
(
IMG_ID INTEGER default 0 not null,
PRED_CLASS_ID INTEGER default 0 not null,
OBJ1_SAMPLE_ID INTEGER default 0 not null,
OBJ2_SAMPLE_ID INTEGER default 0 not null,
primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID),
foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID),
foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID),
foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
|
world_development_indicators | Among the countries in the High income: OECD group whose currency unit is Euro, how many of them have a note on the series code SP.DYN.AMRT.FE? | countries refer to Countrycode; in the high income refers to incomegroup = 'High'; with notes refers to description IS NOT NULL; series code SP.DYN.AMRT.FE refers to Seriescode = 'SP.DYN.AMRT.FE' | SELECT COUNT(T1.Countrycode) FROM Country AS T1 INNER JOIN CountryNotes AS T2 ON T1.CountryCode = T2.Countrycode WHERE T1.IncomeGroup = 'High income: OECD' AND T1.CurrencyUnit = 'Euro' AND T2.Seriescode = 'SP.DYN.AMRT.FE' | CREATE TABLE IF NOT EXISTS "Country"
(
CountryCode TEXT not null
primary key,
ShortName TEXT,
TableName TEXT,
LongName TEXT,
Alpha2Code TEXT,
CurrencyUnit TEXT,
SpecialNotes TEXT,
Region TEXT,
IncomeGroup TEXT,
Wb2Code TEXT,
NationalAccountsBaseYear TEXT,
NationalAccountsReferenceYear TEXT,
SnaPriceValuation TEXT,
LendingCategory TEXT,
OtherGroups TEXT,
SystemOfNationalAccounts TEXT,
AlternativeConversionFactor TEXT,
PppSurveyYear TEXT,
BalanceOfPaymentsManualInUse TEXT,
ExternalDebtReportingStatus TEXT,
SystemOfTrade TEXT,
GovernmentAccountingConcept TEXT,
ImfDataDisseminationStandard TEXT,
LatestPopulationCensus TEXT,
LatestHouseholdSurvey TEXT,
SourceOfMostRecentIncomeAndExpenditureData TEXT,
VitalRegistrationComplete TEXT,
LatestAgriculturalCensus TEXT,
LatestIndustrialData INTEGER,
LatestTradeData INTEGER,
LatestWaterWithdrawalData INTEGER
);
CREATE TABLE IF NOT EXISTS "Series"
(
SeriesCode TEXT not null
primary key,
Topic TEXT,
IndicatorName TEXT,
ShortDefinition TEXT,
LongDefinition TEXT,
UnitOfMeasure TEXT,
Periodicity TEXT,
BasePeriod TEXT,
OtherNotes INTEGER,
AggregationMethod TEXT,
LimitationsAndExceptions TEXT,
NotesFromOriginalSource TEXT,
GeneralComments TEXT,
Source TEXT,
StatisticalConceptAndMethodology TEXT,
DevelopmentRelevance TEXT,
RelatedSourceLinks TEXT,
OtherWebLinks INTEGER,
RelatedIndicators INTEGER,
LicenseType TEXT
);
CREATE TABLE CountryNotes
(
Countrycode TEXT NOT NULL ,
Seriescode TEXT NOT NULL ,
Description TEXT,
primary key (Countrycode, Seriescode),
FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Footnotes
(
Countrycode TEXT NOT NULL ,
Seriescode TEXT NOT NULL ,
Year TEXT,
Description TEXT,
primary key (Countrycode, Seriescode, Year),
FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Indicators
(
CountryName TEXT,
CountryCode TEXT NOT NULL ,
IndicatorName TEXT,
IndicatorCode TEXT NOT NULL ,
Year INTEGER NOT NULL ,
Value INTEGER,
primary key (CountryCode, IndicatorCode, Year),
FOREIGN KEY (CountryCode) REFERENCES Country(CountryCode)
);
CREATE TABLE SeriesNotes
(
Seriescode TEXT not null ,
Year TEXT not null ,
Description TEXT,
primary key (Seriescode, Year),
foreign key (Seriescode) references Series(SeriesCode)
);
|
human_resources | What is the maximum salary of position "Trainer"? | maximum salary refers to maxsalary; Trainee is a positiontitle | SELECT maxsalary FROM position WHERE positiontitle = 'Trainee' | CREATE TABLE location
(
locationID INTEGER
constraint location_pk
primary key,
locationcity TEXT,
address TEXT,
state TEXT,
zipcode INTEGER,
officephone TEXT
);
CREATE TABLE position
(
positionID INTEGER
constraint position_pk
primary key,
positiontitle TEXT,
educationrequired TEXT,
minsalary TEXT,
maxsalary TEXT
);
CREATE TABLE employee
(
ssn TEXT
primary key,
lastname TEXT,
firstname TEXT,
hiredate TEXT,
salary TEXT,
gender TEXT,
performance TEXT,
positionID INTEGER,
locationID INTEGER,
foreign key (locationID) references location(locationID),
foreign key (positionID) references position(positionID)
);
|
cars | How many of the cars from Japan weighed less than 3000? | from Japan refers to country = 'Japan'; weighed less than 3000 refers to weight < 3000 | SELECT COUNT(*) FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'Japan' AND T4.weight < 3000 | CREATE TABLE country
(
origin INTEGER
primary key,
country TEXT
);
CREATE TABLE price
(
ID INTEGER
primary key,
price REAL
);
CREATE TABLE data
(
ID INTEGER
primary key,
mpg REAL,
cylinders INTEGER,
displacement REAL,
horsepower INTEGER,
weight INTEGER,
acceleration REAL,
model INTEGER,
car_name TEXT,
foreign key (ID) references price(ID)
);
CREATE TABLE production
(
ID INTEGER,
model_year INTEGER,
country INTEGER,
primary key (ID, model_year),
foreign key (country) references country(origin),
foreign key (ID) references data(ID),
foreign key (ID) references price(ID)
);
|
retail_complains | What is the first name of clients who have the highest priority? | first name refers to first; highest priority refers to priority = 2 | SELECT T1.first FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.priority = ( SELECT MAX(priority) FROM callcenterlogs ) | CREATE TABLE state
(
StateCode TEXT
constraint state_pk
primary key,
State TEXT,
Region TEXT
);
CREATE TABLE callcenterlogs
(
"Date received" DATE,
"Complaint ID" TEXT,
"rand client" TEXT,
phonefinal TEXT,
"vru+line" TEXT,
call_id INTEGER,
priority INTEGER,
type TEXT,
outcome TEXT,
server TEXT,
ser_start TEXT,
ser_exit TEXT,
ser_time TEXT,
primary key ("Complaint ID"),
foreign key ("rand client") references client(client_id)
);
CREATE TABLE client
(
client_id TEXT
primary key,
sex TEXT,
day INTEGER,
month INTEGER,
year INTEGER,
age INTEGER,
social TEXT,
first TEXT,
middle TEXT,
last TEXT,
phone TEXT,
email TEXT,
address_1 TEXT,
address_2 TEXT,
city TEXT,
state TEXT,
zipcode INTEGER,
district_id INTEGER,
foreign key (district_id) references district(district_id)
);
CREATE TABLE district
(
district_id INTEGER
primary key,
city TEXT,
state_abbrev TEXT,
division TEXT,
foreign key (state_abbrev) references state(StateCode)
);
CREATE TABLE events
(
"Date received" DATE,
Product TEXT,
"Sub-product" TEXT,
Issue TEXT,
"Sub-issue" TEXT,
"Consumer complaint narrative" TEXT,
Tags TEXT,
"Consumer consent provided?" TEXT,
"Submitted via" TEXT,
"Date sent to company" TEXT,
"Company response to consumer" TEXT,
"Timely response?" TEXT,
"Consumer disputed?" TEXT,
"Complaint ID" TEXT,
Client_ID TEXT,
primary key ("Complaint ID", Client_ID),
foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
foreign key (Client_ID) references client(client_id)
);
CREATE TABLE reviews
(
"Date" DATE
primary key,
Stars INTEGER,
Reviews TEXT,
Product TEXT,
district_id INTEGER,
foreign key (district_id) references district(district_id)
);
|
olympics | What is the average age of competitors who participated in 1988 Winter? | AVG(age) where games_name = '1988 Winter'; | SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.games_name = '1988 Winter' | 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)
);
|
book_publishing_company | What is the average level employees working as Managing Editor are at? How many levels are there between the average level and the highest level? | Managing Editor is a job description which refers to job_desc; job level refers to job_lvl; highest level job refers to max_lvl; levels between the average level and the highest level = SUBTRACT(max_lvl; AVG(job_lvl)) | SELECT AVG(T2.job_lvl), T1.max_lvl - AVG(T2.job_lvl) FROM jobs AS T1 INNER JOIN employee AS T2 ON T1.job_id = T2.job_id WHERE T1.job_desc = 'Managing Editor' GROUP BY T2.job_id, T1.max_lvl | CREATE TABLE authors
(
au_id TEXT
primary key,
au_lname TEXT not null,
au_fname TEXT not null,
phone TEXT not null,
address TEXT,
city TEXT,
state TEXT,
zip TEXT,
contract TEXT not null
);
CREATE TABLE jobs
(
job_id INTEGER
primary key,
job_desc TEXT not null,
min_lvl INTEGER not null,
max_lvl INTEGER not null
);
CREATE TABLE publishers
(
pub_id TEXT
primary key,
pub_name TEXT,
city TEXT,
state TEXT,
country TEXT
);
CREATE TABLE employee
(
emp_id TEXT
primary key,
fname TEXT not null,
minit TEXT,
lname TEXT not null,
job_id INTEGER not null,
job_lvl INTEGER,
pub_id TEXT not null,
hire_date DATETIME not null,
foreign key (job_id) references jobs(job_id)
on update cascade on delete cascade,
foreign key (pub_id) references publishers(pub_id)
on update cascade on delete cascade
);
CREATE TABLE pub_info
(
pub_id TEXT
primary key,
logo BLOB,
pr_info TEXT,
foreign key (pub_id) references publishers(pub_id)
on update cascade on delete cascade
);
CREATE TABLE stores
(
stor_id TEXT
primary key,
stor_name TEXT,
stor_address TEXT,
city TEXT,
state TEXT,
zip TEXT
);
CREATE TABLE discounts
(
discounttype TEXT not null,
stor_id TEXT,
lowqty INTEGER,
highqty INTEGER,
discount REAL not null,
foreign key (stor_id) references stores(stor_id)
on update cascade on delete cascade
);
CREATE TABLE titles
(
title_id TEXT
primary key,
title TEXT not null,
type TEXT not null,
pub_id TEXT,
price REAL,
advance REAL,
royalty INTEGER,
ytd_sales INTEGER,
notes TEXT,
pubdate DATETIME not null,
foreign key (pub_id) references publishers(pub_id)
on update cascade on delete cascade
);
CREATE TABLE roysched
(
title_id TEXT not null,
lorange INTEGER,
hirange INTEGER,
royalty INTEGER,
foreign key (title_id) references titles(title_id)
on update cascade on delete cascade
);
CREATE TABLE sales
(
stor_id TEXT not null,
ord_num TEXT not null,
ord_date DATETIME not null,
qty INTEGER not null,
payterms TEXT not null,
title_id TEXT not null,
primary key (stor_id, ord_num, title_id),
foreign key (stor_id) references stores(stor_id)
on update cascade on delete cascade,
foreign key (title_id) references titles(title_id)
on update cascade on delete cascade
);
CREATE TABLE titleauthor
(
au_id TEXT not null,
title_id TEXT not null,
au_ord INTEGER,
royaltyper INTEGER,
primary key (au_id, title_id),
foreign key (au_id) references authors(au_id)
on update cascade on delete cascade,
foreign key (title_id) references titles (title_id)
on update cascade on delete cascade
);
|
video_games | When was the "Adventure Island" game released? | when refers to release_year; the "Adventure Island" game refers to game_name = 'Adventure Island' | SELECT T3.release_year FROM game AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.game_id INNER JOIN game_platform AS T3 ON T2.id = T3.game_publisher_id WHERE T1.game_name = 'Adventure Island' | CREATE TABLE genre
(
id INTEGER not null
primary key,
genre_name TEXT default NULL
);
CREATE TABLE game
(
id INTEGER not null
primary key,
genre_id INTEGER default NULL,
game_name TEXT default NULL,
foreign key (genre_id) references genre(id)
);
CREATE TABLE platform
(
id INTEGER not null
primary key,
platform_name TEXT default NULL
);
CREATE TABLE publisher
(
id INTEGER not null
primary key,
publisher_name TEXT default NULL
);
CREATE TABLE game_publisher
(
id INTEGER not null
primary key,
game_id INTEGER default NULL,
publisher_id INTEGER default NULL,
foreign key (game_id) references game(id),
foreign key (publisher_id) references publisher(id)
);
CREATE TABLE game_platform
(
id INTEGER not null
primary key,
game_publisher_id INTEGER default NULL,
platform_id INTEGER default NULL,
release_year INTEGER default NULL,
foreign key (game_publisher_id) references game_publisher(id),
foreign key (platform_id) references platform(id)
);
CREATE TABLE region
(
id INTEGER not null
primary key,
region_name TEXT default NULL
);
CREATE TABLE region_sales
(
region_id INTEGER default NULL,
game_platform_id INTEGER default NULL,
num_sales REAL default NULL,
foreign key (game_platform_id) references game_platform(id),
foreign key (region_id) references region(id)
);
|
airline | For the flight with the tail number 'N702SK', which air carrier does it belong to? | tail number refers to TAIL_NUM; TAIL_NUM = 'N702SK'; | 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 = 'N702SK' 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)
);
|
mental_health_survey | From 2016 to 2019, how many users each year were asked the question 13? | From 2016 to 2019 refer to SurveyID 2016 BETWEEN 2019; Question 13 refer to QuestionID | SELECT SurveyID, COUNT(UserID) FROM Answer WHERE QuestionID = 13 AND SurveyID BETWEEN 2016 AND 2019 GROUP BY SurveyID | 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)
);
|